PV204 Security technologies

Slides:



Advertisements
Similar presentations
Chapter 3 Public Key Cryptography and Message authentication.
Advertisements

Boneh-Franklin Identity-based Encryption. 2 Symmetric bilinear groups G = ágñ, g p = 1 e: G G G t Bilinear i.e. e(u a, v b ) = e(u, v) ab Non-degenerate:
RSA COSC 201 ST. MARY’S COLLEGE OF MARYLAND FALL 2012 RSA.
CS 483 – SD SECTION BY DR. DANIYAL ALGHAZZAWI (3) Information Security.
Spring 2000CS 4611 Security Outline Encryption Algorithms Authentication Protocols Message Integrity Protocols Key Distribution Firewalls.
Is there Safety in Numbers against Side Channel Leakage? Colin D. Walter UMIST, Manchester, UK
Public Key Cryptosystems - RSA Receiver Sender Eavesdroppe r p q p q p q p and q prime.
Data encryption with big prime numbers
C ● O ● M ● O ● D ● O RESEARCH LAB Longer Keys may Facilitate Side Channel Attacks (Bradford, UK) Colin.
Session 4 Asymmetric ciphers.
Side-Channel Attacks on Smart Cards. Timing Analysis Cryptosystems take different amount of time to process different inputs. Performance optimisations.
How cryptography is used to secure web services Josh Benaloh Cryptographer Microsoft Research.
Tallinn University of Technology Quantum computer impact on public key cryptography Roman Stepanenko.
The RSA Algorithm Rocky K. C. Chang, March
Public Key Encryption and the RSA Public Key Algorithm CSCI 5857: Encoding and Encryption.
9th IMA Conference on Cryptography & Coding Dec 2003 More Detail for a Combined Timing and Power Attack against Implementations of RSA Werner Schindler.
How cryptography is used to secure web services Josh Benaloh Cryptographer Microsoft Research.
Implementing RSA Encryption in Java
Public-Key Encryption
CHES 2002 Presented at the workshop CHES 2002, August 13-15, 2002, Redwood Shores, California, USA.
CSE 311: Foundations of Computing Fall 2014 Lecture 12: Primes, GCD.
Sliding Windows Succumbs to Big Mac Attack Colin D. Walter
Lecture 6.1: Misc. Topics: Number Theory CS 250, Discrete Structures, Fall 2011 Nitesh Saxena.
Faster Implementation of Modular Exponentiation in JavaScript
WISA 2007 Jeju Island, Korea, 27th – 29th Aug 2007 Longer Randomly Blinded RSA Keys may be Weaker than Shorter Ones Colin D. Walter
CSE 311: Foundations of Computing Fall 2013 Lecture 11: Modular arithmetic and applications.
Introduction to Elliptic Curve Cryptography CSCI 5857: Encoding and Encryption.
Data encryption with big prime numbers DANIEL FREEMAN, SLU.
Lecture 9 Overview. RSA Invented by Cocks (GCHQ), independently, by Rivest, Shamir and Adleman (MIT) Two keys e and d used for Encryption and Decryption.
CSCE 715: Network Systems Security Chin-Tser Huang University of South Carolina.
Lecture 6. RSA Use in Encryption to encrypt a message M the sender: – obtains public key of recipient PU={e,n} – computes: C = M e mod n, where 0≤M
Copyright © Zeph Grunschlag, RSA Encryption Zeph Grunschlag.
1 The RSA Algorithm Rocky K. C. Chang February 23, 2007.
LAB#6 MAC & MASSAGE DIGEST CPIT 425. Message Authentication 2  Message authentication is a mechanism used to verify the integrity of a message.  Message.
@Yuan Xue CS 285 Network Security Public-Key Cryptography Yuan Xue Fall 2012.
PV204 Security technologies
Public Key Cryptography
Simple Power Analysis of
PV204 Security technologies
PV204 Security technologies LABS
Attacks on Public Key Encryption Algorithms
Security Outline Encryption Algorithms Authentication Protocols
Network Security Design Fundamentals Lecture-13
RSA Slides by Kent Seamons and Tim van der Horst
D. Cheung – IQC/UWaterloo, Canada D. K. Pradhan – UBristol, UK
This Week: Integers Integers Summary
PV204 Security technologies LABS
CSCE 548 Secure Software Development Final Exam – Review 2016
PV204 Security technologies
Outline of implementation
Public Key Cryptosystems - RSA
Topic 5: Constructing Secure Encryption Schemes
Distinguishing Exponent Digits by Observing Modular Subtractions
Random Number Generation
Cryptography Lecture 10.
Lecture 20 Guest lecturer: Neal Gupta
Representing Information (2)
Cryptographic Timing Attacks
Arithmetic Topics Basic operations Programming Implications
Representing Information (2)
Key Establishment Protocols ~
Cryptographic Hash Functions Part I
Introduction to Elliptic Curve Cryptography
Chapter 29 Cryptography and Network Security
Practical Aspects of Modern Cryptography
Cryptography Lecture 9.
Cryptography Lecture 16.
Stream Cipher Structure
Information and Computer Security CPIS 312 Lab 3
Presentation transcript:

PV204 Security technologies Trusted element, side channels attacks Petr Švenda svenda@fi.muni.cz Faculty of Informatics, Masaryk University

The masterplan for this lab Implementation of modular exponentiation (RSA) Understand naïve and square&multiply algorithm Toy example with integers (32 bits) Understand how to measure operation (clock()) Pre-prepared functions – console or file output Visualization of multiple measurements (R, http://plot.ly) What can be inferred from measurements Use large datatype MPI instead of int (> 102 bits) Understand blinding as protection technique Homework | PV204 Trusted element 25.2.2016

Naïve vs. square and multiply algorithm SideChannelExercise.zip source code from IS Inspect naïve and square&multiply algorithm Limited to integers (unsigned long) for simplicity Measure timings Pre-prepared measurement functions measureExponentiation() clock() used for measurement (1ms granularity) Identify dependency of algorithm on secret value | PV204 Trusted element 25.2.2016

Naïve modular exponentiation algorithm typedef unsigned long ULONG; const int ULONG_LENGTH = sizeof(ULONG); ULONG naiveExponentiation(ULONG message, ULONG exponent, ULONG modulus) { ULONG result = message; for (int i = 1; i < exponent; i++) { // result = (result * message) % modulus; // this may cause type overflow result *= message; result %= modulus; } return result; What is disadvantage of this algorithm? Is algorithm vulnerable to timing side-channel? Is algorithm vulnerable to another side-channel? | PV204 Trusted element 25.2.2016

typedef unsigned long ULONG; const int ULONG_LENGTH = sizeof(ULONG); ULONG squareAndMultiply(ULONG message, ULONG exponent, ULONG modulus) { // Obtain effective length of exponent in bits int sizeExponent = ULONG_LENGTH; ULONG mask = 1; ULONG bit = 0; for (int i = 0; i < ULONG_LENGTH * 8; i++) { bit = exponent & mask; if (bit != 0) { sizeExponent = i + 1; } mask <<= 1; } // Compute square and multiply algorithm ULONG result = 1; for (int i = sizeExponent - 1; i >= 0; i--) { //result = (result * result) % modulus; // this may cause type overflow result *= result; result %= modulus; if ((exponent & (1 << i)) != 0) { // given bit is not 0 // result = (result * message) % modulus; // this may cause type overflow result *= message; return result; | PV204 Trusted element 25.2.2016

Square&multiply algorithm Pre-prepared function squareAndMultiply() What is advantage of this algorithm? Is algorithm vulnerable to timing side-channel? Which part of code is dependent on secret value? measureExponentiation(65535, 65535, 10000003L, SQUAREANDMULTIPLY); What is the time required to complete operation? What are implication for attacker’s ability to mount timing attack? How to mask dependency on secret exponent? Is int (ULONG) enough for cryptographic security? | PV204 Trusted element 25.2.2016

Big integers (MPI from PolarSSL) 32 bits are not enough, 4096 is recommended No native type in C/C++, use PolarSSL’s MPI void squareAndMultiplyMPI(const mpi* message, const mpi* exponent, const mpi* modulus, mpi* result) { // Obtain length of exponent in bits int sizeExponent = 0; int maxBitLength = mpi_size(exponent) * 8; for (int i = 0; i < maxBitLength; i++) { if (mpi_get_bit(exponent, i) != 0) { sizeExponent = i + 1; } } // Compute square and multiply algorithm mpi_lset(result, 1); for (int i = sizeExponent - 1; i >= 0; i--) { mpi_mul_mpi(result, result, result); // result *= result; mpi_mod_mpi(result, result, modulus); // result %= modulus; if (mpi_get_bit(exponent, i) != 0) { // given bit is not 0 mpi_mul_mpi(result, result, message); mpi_mod_mpi(result, result, modulus); }} | PV204 Trusted element 25.2.2016

Create large pseudo-random MPI mpi message; mpi_init(&message); mpi exponent; mpi_init(&exponent); mpi modulus; mpi_init(&modulus); // Cryptographically large number (2048b) const int NUMBER_SIZE = 256; // Init with pseudorandom values (prng will always start with same value) mpi_fill_random(&message, NUMBER_SIZE, generateRNG, NULL); mpi_fill_random(&exponent, NUMBER_SIZE, generateRNG, NULL); mpi_fill_random(&modulus, NUMBER_SIZE, generateRNG, NULL); // Fix MSb and LSb of modulus to 1 modulus.p[0] |= 1; mpi_set_bit(&modulus, 1, 1); measureExponentiationMPI(&message, &exponent, &modulus, SQUAREANDMULTIPLY); | PV204 Trusted element 25.2.2016

Measure times with MPI Operation with large MPI can be measured 100s-1000s ms Visualize histogram of multiple measurements Pre-prepared measurements functions with file output measureExponentiationRepeat() https://plot.ly (Histogram, Traces->Range/bins 1) Try repeated measurement with same data Try repeated measurement with different data Are measured times constant? Why? | PV204 Trusted element 25.2.2016

Fix: Blinding Create squareAndMultiplyBlindedMPI() as improved version of squareAndMultiplyMPI() Generate random value r and compute re mod N Compute blinded ciphertext b = c * re mod N Decrypt b and then divide result by r | PV204 Trusted element 25.2.2016

Homework Finalize implementation of blinding of argument with MPI Create unit tests that will verify identical functionality squareAndMultiplyMPI and squareAndMultiplyBlindedMPI Perform analysis of blinded and non-blinded version Timing results for 1000 measurements Visualized histograms Scenario 1: Same data Scenario 2: Same exponent, low hamming weight of data Scenario 3: Same exponent, high hamming weight of data Scenario 4: Low/high hw exponent and random data Discuss the difference observed Discuss feasibility of attack against non-blinded version | PV204 Trusted element 25.2.2016

Homework – what to submit Source code of your blinded operation Test showing that it computes correctly 2 pages of text and figures Visualized measurements (histograms, 4 scenarios) Discussion of difference observed Discussing of feasibility of attack against blinded/non-blinded implementation Submit before 4.3. 6:00am into IS HW vault | PV204 Trusted element 25.2.2016