SlideShare a Scribd company logo
1 of 68
Download to read offline
The Long Journey from
Papers to Software:
Crypto APIs
Pascal Junod
HES-SO / HEIG-VD
IACR School on Design and Security of Cryptographic Algorithms and Devices
October 18-23, 2015 - Sardinia / Italy
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Agenda
• Introduction
• Security models and primitives
• Choice of security parameters / configuration
• Generation of parameters
• Conclusion
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Introduction
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
At least 99.9999999857% of
the users of crypto libraries
are not djb.
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Yet, many people use crypto
libraries on a daily basis.
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
They often do it in a
wrong way.
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Why?
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
What this talk is not about
• Blaming arrogant cryptographers that do not know or
do not care about programming and software
development
• Trashing ignorant crypto libraries developers that do
not know everything about cryptography
• Laughing at 99.9995% of crypto libraries users that do
horrible mistakes most of the time
• Security of software cryptographic implementations
with respect to grey- and white-box adversaries
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
What this talk is about
• Exposing a real problem that arises every day in
practice: the lack of security-related usability in
most cryptographic libraries
• Showing a sample of today’s good and bad
practices
• Sketch usability requirements on cryptographic
libraries
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Security of a
Cryptographic Library
Cryptographic
Security
Side-Channel
Security
Software
Security
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Security
Model
Crypto
Primitives
Security
Parameter
Crypto
Parameters
Good crypto
design
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Security Models and
Crypto Primitives
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Security Models
• In the private-key setting, cryptographers are used
to deal with different security models:
• Indistinguishability in the presence of an
eavesdropper
• Indistinguishability under a CPA
• Indistinguishability under a CCA
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Security Models
• In practice, facing a passive adversary only is extremely
infrequent.
• Very likely, what one is looking for is authenticated
encryption (or a MAC if no confidentiality is required)
• Two reasonable options for a user:
• Use an authenticated encryption mode equipped with a
proper block cipher (e.g. AES-GCM)
• Use an encrypt-then-authenticate construction (e.g.
AES-CTR + CBC-MAC-AES + HKDF)
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
What Could Go Wrong?
• Use AES in ECB mode
• Use AES in CBC mode with constant IV
• Use AES in CBC mode with random IV
• Use AES in CBC mode with random IV, CBC-MAC
on the ciphertext, all with the same key
• etc.
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Facts
• Many SW crypto libraries offer the possibility to
use:
• insecure ciphers (e.g. DES, RC4, …);
• secure ciphers without modes of operations;
• secure ciphers with insecure modes of
operations (e.g. AES-ECB);
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Facts
• Many SW crypto libraries offer the possibility to use:
• secure ciphers with secure modes of operation, but
with insecure parameters (e.g. AES-CBC with constant
IV);
• secure ciphers with secure modes of operation, but
without authentication (e.g. AES-CBC with random IV);
• the same key for ciphering and authentication;
• etc.
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
How it Should Work?
• Offer only high-level APIs (like data_seal(),
data_encrypt()) providing:
• secure choice of security model (i.e.
authenticated encryption);
• secure choice of primitives;
• secure handling of IVs and keys.
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
How it Should Work?
• If willing to offer more capabilities:
• Force the developper to build library with
-DUSE_LOW_LEVEL_API for having access to
CPA-secure modes of operations.
• Warn at compilation time and in debug
configuration for every use of a low-level API.
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
How it Should Work?
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
In Practice: Botan
Is more algos really better?
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
In Practice: libsodium
Algorithms:
• Chacha20 + Poly1305
MAC
• HMAC-SHA512/256
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Facts
• Many SW crypto libraries offer the possibility to use:
• non-cryptographic algorithms (e.g. CRC32,
ADLER, Mersenne Twister)
• insecure ciphers/algorithms (e.g. DES, RC4,
MD5, SHA1, insecure variants of CBC-MAC);
• insecure protocols (e.g. SSL 2.0, SSL 3.0)
• insecure cipher suites
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
How it Should Work?
• If really willing to offer more capabilities:
• Force the developer to build lib with
-DUSE_WEAK_CIPHERS for having access to
weaker or obsolete ciphers and protocols (64-bit
blocks, RC4, DES, SSL 2.0, 3.0, etc.)
• Additionally, warn at compilation time and in
debug configuration at every use of a weak
cipher, hash, MAC protocol or non-cryptographic
function
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Idea of Self-Defending
Primitives
• Triple-DES: self-defending implementation should
check that !(k1 == k2 == k3)
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Idea of Self-Defending
Primitives
• Other example: PyCrypto counter mode API
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Idea of Self-Defending
Primitives
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Idea of Self-Defending
Primitives
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Idea of Self-Defending
Primitives
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
How it Should Work?
Offer only capabilities that are useful for developers
and that, at the same time, do not allow him/her to
generate security-related mistakes.
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Choice of Security
Parameter
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Idea of Self-Defending
Primitives
• Blowfish, RC5, etc.: emit a warning, or better,
refuse to key-schedule in normal conditions when
the key length is smaller than 80 bits.
• For instance, libgcrypt implementation of
Blowfish key-schedule does a self-test, looks for
weak keys, but allows 32-bit keys.
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
RSA
• Most libraries don’t tell anything when you generate
an RSA key with a too small key length.
• In 2015, we know that 1024 bits is a strict minimum
only valid for data with a very short life, and that we
should use at least 1536-bit keys, better 2048-bit
ones.
• Yet…
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
RSA
nowhere:apps pjunod$./openssl version
OpenSSL 1.0.2d 9 Jul 2015
nowhere:apps pjunod$ ./openssl genrsa
Generating RSA private key, 2048 bit long modulus
..............................................................
.......................................+++..+++
e is 65537 (0x10001)
-----BEGIN RSA PRIVATE KEY-----
[…]
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
RSA
nowhere:apps pjunod$ openssl version
OpenSSL 0.9.8zg 14 July 2015
nowhere:apps pjunod$ openssl genrsa
Generating RSA private key, 512 bit long modulus
...............++++++++++++
.......++++++++++++
e is 65537 (0x10001)
-----BEGIN RSA PRIVATE KEY-----
[…]
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
RSA
nowhere:apps pjunod$ ./openssl genrsa 128
Generating RSA private key, 128 bit long modulus
..+++++++++++++++++++++++++++
..+++++++++++++++++++++++++++
e is 65537 (0x10001)
-----BEGIN RSA PRIVATE KEY-----
MGMCAQACEQDCz4LBaILQw62vAnvJcGYXAgMBAAECEA3z+vOLXsNBALIVFQBUmLEC
CQDkWMf0wgBiuwIJANpnCdIa3/pVAgkAqaQLaRp3juECCHWEfARR8bMBAgkAzEYS
ZrcEG/w=
-----END RSA PRIVATE KEY-----
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
RSA
nowhere:apps pjunod$ ./openssl genrsa 64
Generating RSA private key, 64 bit long modulus
.+++++++++++++++++++++++++++
.+++++++++++++++++++++++++++
e is 65537 (0x10001)
-----BEGIN RSA PRIVATE KEY-----
MD4CAQACCQDFAmoNN7zQsQIDAQABAgkAukcZG/LFpR0CBQDvmYDHAgUA0n6axwIE
ANgyqwIEX7qeTwIEZw+/Gw==
-----END RSA PRIVATE KEY-----
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
RSA
nowhere:apps pjunod$ ./openssl genrsa 32
Generating RSA private key, 32 bit long modulus
.+++++++++++++++++++++++++++
.+++++++++++++++++++++++++++
e is 65537 (0x10001)
-----BEGIN RSA PRIVATE KEY-----
MCwCAQACBQDSdAJdAgMBAAECBFjnEKkCAwD6BwIDANd7AgIYfwICMeMCAwCMFQ
==
-----END RSA PRIVATE KEY-----
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
RSA
openssl:openssl pjunod$ pwd
/Users/pjunod/data/science/work/crypto-APIS/libs/libressl/libressl-2.3.0/
apps/openssl
eduroam-3-153:openssl pjunod$ ./openssl genrsa 32
Generating RSA private key, 32 bit long modulus
.+++++++++++++++++++++++++++
.+++++++++++++++++++++++++++
e is 65537 (0x10001)
-----BEGIN RSA PRIVATE KEY-----
MCsCAQACBQCcGCAdAgMBAAECBAv8q50CAwDL/wIDAMPjAgIFswICWYkCAkV5
-----END RSA PRIVATE KEY-----
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
RSA / OpenSSL
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
RSA / Botan
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
RSA / Crypto++
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
RSA / libgcrypt
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
RSA / wolfcrypt
nowhere:src pjunod$ pwd
/Users/pjunod/data/science/work/crypto-APIS/libs/
wolfSSL/wolfssl-3.6.8/wolfcrypt/src
nowhere:src pjunod$ grep RSA_MIN_SIZE *.c
rsa.c: RSA_MIN_SIZE = 512,
rsa.c: if (size < RSA_MIN_SIZE || size >
RSA_MAX_SIZE)
nowhere:src pjunod$ grep RSA_MAX_SIZE *.c
rsa.c: RSA_MAX_SIZE = 4096,
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Other Public Key Algos
• ./openssl gendh 128
• ./openssl ecparams -list_curves
secp112r1, secp112r2, secp128r1, secp128r2,
sect113r1, sect113r2, sect131r1, sect131r2,
wap-wsg-idm-ecid-wtls1, wap-wsg-idm-ecid-
wtls4, wap-wsg-idm-ecid-wtls6, wap-wsg-idm-
ecid-wtls8, Oakley-EC2N-3, Oakley-EC2N-4,
…
• SSL/TLS obsolete or weak cipher suites
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
RSA / Keyczar
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
How it Should Work?
• Offer only security parameters, configuration
options that are meaningful in terms of security!
• Offer safe values by default, always!
• If really required, weaker/obsolete variants could
be made available, but requiring an effort from the
developper, emitting warnings at compilation time,
etc.
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Generation of Non-
Secret Parameters
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Parameters
• Cryptographic algorithms and implementations use
parameters all the time, that are secret or not:
• Keys
• IVs
• Nonces
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Parameters
• An issue of tremendous importance is the
availability of cryptographically secure random
numbers.
• Most cryptographic libraries do a rather good job in
providing a secure CPRNG to the developer.
• However, most cryptographic libraries put the
responsibility to use the CPRNG on the
developer shoulders.
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Parameters
• If the responsibility to use a CPRNG is left to the
developers, two bad things can happen:
• Forget to use random values
• Use a non-cryptographic PRNG
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Parameters
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Parameters
• For instance:
Generating the
nonce is the
user’s
responsibility.
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Parameters
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Parameters
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Parameters
Generating the
nonce is the API’s
responsibility.
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
How it Should Work?
In encryption mode, the IVs/nonces should,
whenever possible, be generated in a transparent
way and returned by the API, as it is done for public-
key crypto.
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Error Handling
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Error Handling
if (!ECDSA_sign (…)) { handle_error (); }
if (ECDSA_verify (…)) { /* good signature */…}
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Error Handling
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Errors Handling
nowhere:rsa pjunod$ grep ERR_REASON
rsa_err.c | wc -l
68
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
How it Should Work?
• In debug mode, a crypto library should return
detailed error messages.
• In production mode, a crypto library should return
two types of return value: OK / NOK.
• Error handling should be as simple as possible.
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Conclusion
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Conclusions
• In a crypto library, a non-secure functionality is
a superfluous functionality that must be killed.
• Crypto libraries should stop assuming that its
crypto library users are omniscient
cryptographers. 99.999% of them are not.
• In consequence, crypto libraries should stop
put security-related responsibilities on
developers’ shoulders as much as possible.
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
Conclusions
• A crypto library should categorically refuse to
generate too small keys or cryptographic groups.
• A crypto library should refuse with all possible energy
to use obsolete/weak cryptographic configurations.
• Whenever possible, a crypto library should generate
itself the required IVs/nonces and return them to the
user.
• A crypto library should have the cleanest and
simplest possible error handling mechanism.
IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
The perfect
cryptographic library
does not exist yet, even
if a few of them converge
in the good direction!
The Long Journey from
Papers to Software:
Crypto APIs
Pascal Junod
HES-SO / HEIG-VD
IACR School on Design and Security of Cryptographic Algorithms and Devices
October 18-23, 2015 - Sardinia / Italy

More Related Content

What's hot

Track f interoperable ip-delivery_ch_e ofer shragay
Track f   interoperable ip-delivery_ch_e ofer shragayTrack f   interoperable ip-delivery_ch_e ofer shragay
Track f interoperable ip-delivery_ch_e ofer shragay
chiportal
 

What's hot (8)

Slide Deck – Session 8 – FRSecure CISSP Mentor Program 2017
Slide Deck – Session 8 – FRSecure CISSP Mentor Program 2017Slide Deck – Session 8 – FRSecure CISSP Mentor Program 2017
Slide Deck – Session 8 – FRSecure CISSP Mentor Program 2017
 
Slide Deck – Session 9 – FRSecure CISSP
Slide Deck – Session 9 – FRSecure CISSP Slide Deck – Session 9 – FRSecure CISSP
Slide Deck – Session 9 – FRSecure CISSP
 
Zerotrusting serverless applications protecting microservices using secure d...
Zerotrusting serverless applications  protecting microservices using secure d...Zerotrusting serverless applications  protecting microservices using secure d...
Zerotrusting serverless applications protecting microservices using secure d...
 
Track f interoperable ip-delivery_ch_e ofer shragay
Track f   interoperable ip-delivery_ch_e ofer shragayTrack f   interoperable ip-delivery_ch_e ofer shragay
Track f interoperable ip-delivery_ch_e ofer shragay
 
Certificates, PKI, and SSL/TLS for infrastructure builders and operators
Certificates, PKI, and SSL/TLS for infrastructure builders and operatorsCertificates, PKI, and SSL/TLS for infrastructure builders and operators
Certificates, PKI, and SSL/TLS for infrastructure builders and operators
 
iOS application (in)security
iOS application (in)securityiOS application (in)security
iOS application (in)security
 
Stop Passing the Bug: IoT Supply Chain Security
Stop Passing the Bug: IoT Supply Chain SecurityStop Passing the Bug: IoT Supply Chain Security
Stop Passing the Bug: IoT Supply Chain Security
 
Containers At-Risk: A Review of 21,000 Cloud Environments
Containers At-Risk: A Review of 21,000 Cloud EnvironmentsContainers At-Risk: A Review of 21,000 Cloud Environments
Containers At-Risk: A Review of 21,000 Cloud Environments
 

Viewers also liked

מצגת כללית- 2015
מצגת כללית- 2015 מצגת כללית- 2015
מצגת כללית- 2015
Pinni Ost
 

Viewers also liked (12)

Трикутники 10.02.15
Трикутники 10.02.15Трикутники 10.02.15
Трикутники 10.02.15
 
собрание 22декабря
собрание 22декабрясобрание 22декабря
собрание 22декабря
 
Wp location
Wp locationWp location
Wp location
 
מצגת כללית- 2015
מצגת כללית- 2015 מצגת כללית- 2015
מצגת כללית- 2015
 
Global Business and public relations
Global Business and public relations Global Business and public relations
Global Business and public relations
 
игра марафон 16
игра марафон 16игра марафон 16
игра марафон 16
 
які бувають трикутники
які бувають трикутникиякі бувають трикутники
які бувають трикутники
 
Cуміжні кути та їх властивості
Cуміжні кути та їх властивостіCуміжні кути та їх властивості
Cуміжні кути та їх властивості
 
Microsoft 70-331 Share Point Server 2013 Complete Training
Microsoft 70-331 Share Point Server 2013 Complete TrainingMicrosoft 70-331 Share Point Server 2013 Complete Training
Microsoft 70-331 Share Point Server 2013 Complete Training
 
урок на конкурс2016
урок на конкурс2016урок на конкурс2016
урок на конкурс2016
 
70-646 Windows Server 2008 Server Administrator
 70-646 Windows Server 2008 Server Administrator 70-646 Windows Server 2008 Server Administrator
70-646 Windows Server 2008 Server Administrator
 
Mazen cv 2011.doc mazen mahfouz for working outside (1)
Mazen  cv 2011.doc mazen mahfouz for working outside (1)Mazen  cv 2011.doc mazen mahfouz for working outside (1)
Mazen cv 2011.doc mazen mahfouz for working outside (1)
 

Similar to The Long Journey from Papers to Software: Crypto APIs

Symmetric key encryption
Symmetric key encryptionSymmetric key encryption
Symmetric key encryption
mdhar123
 
Kubernetes and container security
Kubernetes and container securityKubernetes and container security
Kubernetes and container security
Volodymyr Shynkar
 
Symmetric key encryption new approach
Symmetric key encryption new approachSymmetric key encryption new approach
Symmetric key encryption new approach
mdhar123
 
Analysis of Security and Compliance using Oracle SPARC T-Series Servers: Emph...
Analysis of Security and Compliance using Oracle SPARC T-Series Servers: Emph...Analysis of Security and Compliance using Oracle SPARC T-Series Servers: Emph...
Analysis of Security and Compliance using Oracle SPARC T-Series Servers: Emph...
Ramesh Nagappan
 

Similar to The Long Journey from Papers to Software: Crypto APIs (20)

Encryption symmetric key
Encryption symmetric keyEncryption symmetric key
Encryption symmetric key
 
Symmetric key encryption
Symmetric key encryptionSymmetric key encryption
Symmetric key encryption
 
Kubernetes and container security
Kubernetes and container securityKubernetes and container security
Kubernetes and container security
 
Introduction to cryptography for software developers
Introduction to cryptography for software developersIntroduction to cryptography for software developers
Introduction to cryptography for software developers
 
Symmetric key encryption new approach
Symmetric key encryption new approachSymmetric key encryption new approach
Symmetric key encryption new approach
 
AWS live hack: Docker + Snyk Container on AWS
AWS live hack: Docker + Snyk Container on AWSAWS live hack: Docker + Snyk Container on AWS
AWS live hack: Docker + Snyk Container on AWS
 
Analysis of Security and Compliance using Oracle SPARC T-Series Servers: Emph...
Analysis of Security and Compliance using Oracle SPARC T-Series Servers: Emph...Analysis of Security and Compliance using Oracle SPARC T-Series Servers: Emph...
Analysis of Security and Compliance using Oracle SPARC T-Series Servers: Emph...
 
apidays LIVE London 2021 - API Security in Highly Volatile Threat Landscapes ...
apidays LIVE London 2021 - API Security in Highly Volatile Threat Landscapes ...apidays LIVE London 2021 - API Security in Highly Volatile Threat Landscapes ...
apidays LIVE London 2021 - API Security in Highly Volatile Threat Landscapes ...
 
How to write secure code
How to write secure codeHow to write secure code
How to write secure code
 
Lesson 1
Lesson 1Lesson 1
Lesson 1
 
The Art of Cloud Native Defense on Kubernetes
The Art of Cloud Native Defense on KubernetesThe Art of Cloud Native Defense on Kubernetes
The Art of Cloud Native Defense on Kubernetes
 
Kubernetes Security Best Practices - With tips for the CKS exam
Kubernetes Security Best Practices - With tips for the CKS examKubernetes Security Best Practices - With tips for the CKS exam
Kubernetes Security Best Practices - With tips for the CKS exam
 
How to do Cryptography right in Android Part One
How to do Cryptography right in Android Part OneHow to do Cryptography right in Android Part One
How to do Cryptography right in Android Part One
 
Wi-Fi Security Fundamentals
Wi-Fi Security FundamentalsWi-Fi Security Fundamentals
Wi-Fi Security Fundamentals
 
IRJET- Survey of Cryptographic Techniques to Certify Sharing of Informati...
IRJET-  	  Survey of Cryptographic Techniques to Certify Sharing of Informati...IRJET-  	  Survey of Cryptographic Techniques to Certify Sharing of Informati...
IRJET- Survey of Cryptographic Techniques to Certify Sharing of Informati...
 
Cyber security workshop talk.pptx
Cyber security workshop talk.pptxCyber security workshop talk.pptx
Cyber security workshop talk.pptx
 
apidays Australia 2023 - The Swiss Cheese Model of Layered API Security, Leon...
apidays Australia 2023 - The Swiss Cheese Model of Layered API Security, Leon...apidays Australia 2023 - The Swiss Cheese Model of Layered API Security, Leon...
apidays Australia 2023 - The Swiss Cheese Model of Layered API Security, Leon...
 
Infosecurity.be 2019: What are relevant open source security tools you should...
Infosecurity.be 2019: What are relevant open source security tools you should...Infosecurity.be 2019: What are relevant open source security tools you should...
Infosecurity.be 2019: What are relevant open source security tools you should...
 
INTERFACE by apidays 2023 - The Swiss Cheese Model of Layered API Security, L...
INTERFACE by apidays 2023 - The Swiss Cheese Model of Layered API Security, L...INTERFACE by apidays 2023 - The Swiss Cheese Model of Layered API Security, L...
INTERFACE by apidays 2023 - The Swiss Cheese Model of Layered API Security, L...
 
Chapter 5 Presentation
Chapter 5 PresentationChapter 5 Presentation
Chapter 5 Presentation
 

Recently uploaded

Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
panagenda
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
Muhammad Subhan
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 

Recently uploaded (20)

Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfFrisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهله
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
How to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in PakistanHow to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in Pakistan
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 

The Long Journey from Papers to Software: Crypto APIs

  • 1. The Long Journey from Papers to Software: Crypto APIs Pascal Junod HES-SO / HEIG-VD IACR School on Design and Security of Cryptographic Algorithms and Devices October 18-23, 2015 - Sardinia / Italy
  • 2. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Agenda • Introduction • Security models and primitives • Choice of security parameters / configuration • Generation of parameters • Conclusion
  • 3. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Introduction
  • 4. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy At least 99.9999999857% of the users of crypto libraries are not djb.
  • 5. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Yet, many people use crypto libraries on a daily basis.
  • 6. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy They often do it in a wrong way.
  • 7. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Why?
  • 8. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy What this talk is not about • Blaming arrogant cryptographers that do not know or do not care about programming and software development • Trashing ignorant crypto libraries developers that do not know everything about cryptography • Laughing at 99.9995% of crypto libraries users that do horrible mistakes most of the time • Security of software cryptographic implementations with respect to grey- and white-box adversaries
  • 9. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy What this talk is about • Exposing a real problem that arises every day in practice: the lack of security-related usability in most cryptographic libraries • Showing a sample of today’s good and bad practices • Sketch usability requirements on cryptographic libraries
  • 10. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Security of a Cryptographic Library Cryptographic Security Side-Channel Security Software Security
  • 11. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Security Model Crypto Primitives Security Parameter Crypto Parameters Good crypto design
  • 12. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Security Models and Crypto Primitives
  • 13. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Security Models • In the private-key setting, cryptographers are used to deal with different security models: • Indistinguishability in the presence of an eavesdropper • Indistinguishability under a CPA • Indistinguishability under a CCA
  • 14. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Security Models • In practice, facing a passive adversary only is extremely infrequent. • Very likely, what one is looking for is authenticated encryption (or a MAC if no confidentiality is required) • Two reasonable options for a user: • Use an authenticated encryption mode equipped with a proper block cipher (e.g. AES-GCM) • Use an encrypt-then-authenticate construction (e.g. AES-CTR + CBC-MAC-AES + HKDF)
  • 15. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy What Could Go Wrong? • Use AES in ECB mode • Use AES in CBC mode with constant IV • Use AES in CBC mode with random IV • Use AES in CBC mode with random IV, CBC-MAC on the ciphertext, all with the same key • etc.
  • 16. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Facts • Many SW crypto libraries offer the possibility to use: • insecure ciphers (e.g. DES, RC4, …); • secure ciphers without modes of operations; • secure ciphers with insecure modes of operations (e.g. AES-ECB);
  • 17. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Facts • Many SW crypto libraries offer the possibility to use: • secure ciphers with secure modes of operation, but with insecure parameters (e.g. AES-CBC with constant IV); • secure ciphers with secure modes of operation, but without authentication (e.g. AES-CBC with random IV); • the same key for ciphering and authentication; • etc.
  • 18. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy How it Should Work? • Offer only high-level APIs (like data_seal(), data_encrypt()) providing: • secure choice of security model (i.e. authenticated encryption); • secure choice of primitives; • secure handling of IVs and keys.
  • 19. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy How it Should Work? • If willing to offer more capabilities: • Force the developper to build library with -DUSE_LOW_LEVEL_API for having access to CPA-secure modes of operations. • Warn at compilation time and in debug configuration for every use of a low-level API.
  • 20. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy How it Should Work?
  • 21. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy In Practice: Botan Is more algos really better?
  • 22. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy In Practice: libsodium Algorithms: • Chacha20 + Poly1305 MAC • HMAC-SHA512/256
  • 23. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Facts • Many SW crypto libraries offer the possibility to use: • non-cryptographic algorithms (e.g. CRC32, ADLER, Mersenne Twister) • insecure ciphers/algorithms (e.g. DES, RC4, MD5, SHA1, insecure variants of CBC-MAC); • insecure protocols (e.g. SSL 2.0, SSL 3.0) • insecure cipher suites
  • 24. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy How it Should Work? • If really willing to offer more capabilities: • Force the developer to build lib with -DUSE_WEAK_CIPHERS for having access to weaker or obsolete ciphers and protocols (64-bit blocks, RC4, DES, SSL 2.0, 3.0, etc.) • Additionally, warn at compilation time and in debug configuration at every use of a weak cipher, hash, MAC protocol or non-cryptographic function
  • 25. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Idea of Self-Defending Primitives • Triple-DES: self-defending implementation should check that !(k1 == k2 == k3)
  • 26. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Idea of Self-Defending Primitives • Other example: PyCrypto counter mode API
  • 27. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Idea of Self-Defending Primitives
  • 28. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Idea of Self-Defending Primitives
  • 29. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Idea of Self-Defending Primitives
  • 30. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy How it Should Work? Offer only capabilities that are useful for developers and that, at the same time, do not allow him/her to generate security-related mistakes.
  • 31. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Choice of Security Parameter
  • 32. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Idea of Self-Defending Primitives • Blowfish, RC5, etc.: emit a warning, or better, refuse to key-schedule in normal conditions when the key length is smaller than 80 bits. • For instance, libgcrypt implementation of Blowfish key-schedule does a self-test, looks for weak keys, but allows 32-bit keys.
  • 33. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy RSA • Most libraries don’t tell anything when you generate an RSA key with a too small key length. • In 2015, we know that 1024 bits is a strict minimum only valid for data with a very short life, and that we should use at least 1536-bit keys, better 2048-bit ones. • Yet…
  • 34. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy RSA nowhere:apps pjunod$./openssl version OpenSSL 1.0.2d 9 Jul 2015 nowhere:apps pjunod$ ./openssl genrsa Generating RSA private key, 2048 bit long modulus .............................................................. .......................................+++..+++ e is 65537 (0x10001) -----BEGIN RSA PRIVATE KEY----- […]
  • 35. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy RSA nowhere:apps pjunod$ openssl version OpenSSL 0.9.8zg 14 July 2015 nowhere:apps pjunod$ openssl genrsa Generating RSA private key, 512 bit long modulus ...............++++++++++++ .......++++++++++++ e is 65537 (0x10001) -----BEGIN RSA PRIVATE KEY----- […]
  • 36. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy RSA nowhere:apps pjunod$ ./openssl genrsa 128 Generating RSA private key, 128 bit long modulus ..+++++++++++++++++++++++++++ ..+++++++++++++++++++++++++++ e is 65537 (0x10001) -----BEGIN RSA PRIVATE KEY----- MGMCAQACEQDCz4LBaILQw62vAnvJcGYXAgMBAAECEA3z+vOLXsNBALIVFQBUmLEC CQDkWMf0wgBiuwIJANpnCdIa3/pVAgkAqaQLaRp3juECCHWEfARR8bMBAgkAzEYS ZrcEG/w= -----END RSA PRIVATE KEY-----
  • 37. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy RSA nowhere:apps pjunod$ ./openssl genrsa 64 Generating RSA private key, 64 bit long modulus .+++++++++++++++++++++++++++ .+++++++++++++++++++++++++++ e is 65537 (0x10001) -----BEGIN RSA PRIVATE KEY----- MD4CAQACCQDFAmoNN7zQsQIDAQABAgkAukcZG/LFpR0CBQDvmYDHAgUA0n6axwIE ANgyqwIEX7qeTwIEZw+/Gw== -----END RSA PRIVATE KEY-----
  • 38. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy RSA nowhere:apps pjunod$ ./openssl genrsa 32 Generating RSA private key, 32 bit long modulus .+++++++++++++++++++++++++++ .+++++++++++++++++++++++++++ e is 65537 (0x10001) -----BEGIN RSA PRIVATE KEY----- MCwCAQACBQDSdAJdAgMBAAECBFjnEKkCAwD6BwIDANd7AgIYfwICMeMCAwCMFQ == -----END RSA PRIVATE KEY-----
  • 39. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy RSA openssl:openssl pjunod$ pwd /Users/pjunod/data/science/work/crypto-APIS/libs/libressl/libressl-2.3.0/ apps/openssl eduroam-3-153:openssl pjunod$ ./openssl genrsa 32 Generating RSA private key, 32 bit long modulus .+++++++++++++++++++++++++++ .+++++++++++++++++++++++++++ e is 65537 (0x10001) -----BEGIN RSA PRIVATE KEY----- MCsCAQACBQCcGCAdAgMBAAECBAv8q50CAwDL/wIDAMPjAgIFswICWYkCAkV5 -----END RSA PRIVATE KEY-----
  • 40. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy RSA / OpenSSL
  • 41. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy RSA / Botan
  • 42. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy RSA / Crypto++
  • 43. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy RSA / libgcrypt
  • 44. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy RSA / wolfcrypt nowhere:src pjunod$ pwd /Users/pjunod/data/science/work/crypto-APIS/libs/ wolfSSL/wolfssl-3.6.8/wolfcrypt/src nowhere:src pjunod$ grep RSA_MIN_SIZE *.c rsa.c: RSA_MIN_SIZE = 512, rsa.c: if (size < RSA_MIN_SIZE || size > RSA_MAX_SIZE) nowhere:src pjunod$ grep RSA_MAX_SIZE *.c rsa.c: RSA_MAX_SIZE = 4096,
  • 45. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Other Public Key Algos • ./openssl gendh 128 • ./openssl ecparams -list_curves secp112r1, secp112r2, secp128r1, secp128r2, sect113r1, sect113r2, sect131r1, sect131r2, wap-wsg-idm-ecid-wtls1, wap-wsg-idm-ecid- wtls4, wap-wsg-idm-ecid-wtls6, wap-wsg-idm- ecid-wtls8, Oakley-EC2N-3, Oakley-EC2N-4, … • SSL/TLS obsolete or weak cipher suites
  • 46. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy RSA / Keyczar
  • 47. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy How it Should Work? • Offer only security parameters, configuration options that are meaningful in terms of security! • Offer safe values by default, always! • If really required, weaker/obsolete variants could be made available, but requiring an effort from the developper, emitting warnings at compilation time, etc.
  • 48. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Generation of Non- Secret Parameters
  • 49. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Parameters • Cryptographic algorithms and implementations use parameters all the time, that are secret or not: • Keys • IVs • Nonces
  • 50. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Parameters • An issue of tremendous importance is the availability of cryptographically secure random numbers. • Most cryptographic libraries do a rather good job in providing a secure CPRNG to the developer. • However, most cryptographic libraries put the responsibility to use the CPRNG on the developer shoulders.
  • 51. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Parameters • If the responsibility to use a CPRNG is left to the developers, two bad things can happen: • Forget to use random values • Use a non-cryptographic PRNG
  • 52. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Parameters
  • 53. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Parameters • For instance: Generating the nonce is the user’s responsibility.
  • 54. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Parameters
  • 55. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Parameters
  • 56. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Parameters Generating the nonce is the API’s responsibility.
  • 57. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy
  • 58. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy How it Should Work? In encryption mode, the IVs/nonces should, whenever possible, be generated in a transparent way and returned by the API, as it is done for public- key crypto.
  • 59. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Error Handling
  • 60. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Error Handling if (!ECDSA_sign (…)) { handle_error (); } if (ECDSA_verify (…)) { /* good signature */…}
  • 61. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Error Handling
  • 62. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Errors Handling nowhere:rsa pjunod$ grep ERR_REASON rsa_err.c | wc -l 68
  • 63. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy How it Should Work? • In debug mode, a crypto library should return detailed error messages. • In production mode, a crypto library should return two types of return value: OK / NOK. • Error handling should be as simple as possible.
  • 64. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Conclusion
  • 65. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Conclusions • In a crypto library, a non-secure functionality is a superfluous functionality that must be killed. • Crypto libraries should stop assuming that its crypto library users are omniscient cryptographers. 99.999% of them are not. • In consequence, crypto libraries should stop put security-related responsibilities on developers’ shoulders as much as possible.
  • 66. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy Conclusions • A crypto library should categorically refuse to generate too small keys or cryptographic groups. • A crypto library should refuse with all possible energy to use obsolete/weak cryptographic configurations. • Whenever possible, a crypto library should generate itself the required IVs/nonces and return them to the user. • A crypto library should have the cleanest and simplest possible error handling mechanism.
  • 67. IACR School on Design and Security of Cryptographic Algorithms and Devices - October 18-23, 2015 - Sardinia / Italy The perfect cryptographic library does not exist yet, even if a few of them converge in the good direction!
  • 68. The Long Journey from Papers to Software: Crypto APIs Pascal Junod HES-SO / HEIG-VD IACR School on Design and Security of Cryptographic Algorithms and Devices October 18-23, 2015 - Sardinia / Italy