wolfSSL: Hardened By Default

In cryptography when we talk about hardening a library, we mean enabling resistance to timing attacks and cache attacks, using RSA blinding and protecting against glitching.

Enabling and Disabling

Our code has many related macros which can be controlled via configure script flags such as the harden flag and maxstrength flag. When hardening is enabled, the following flags are defined:

TFM_TIMING_RESISTANT

ECC_TIMING_RESISTANT

WC_RSA_BLINDING

When it is disabled, the following flags are defined:

WC_NO_HARDEN

WC_NO_CACHE_RESISTANT

NOTE: hardening is enabled by default and in most cases should NOT be disabled. Later in this post, we will discuss some guidance on this matter.

The “maxstrength” flag is disabled by default because it only allows AEAD-PFS (Authenticated Encryption with Associated Data - Perfect Forward Secrecy) cipher suites which can cause interoperability issues. However, when it is enabled, it defines WOLFSSL_CIPHER_TEXT_CHECK, which protects against glitching attacks. If you want other cipher suites to be available, but also want glitching protection for the relevant ciphersuites, you can add -DWOLFSSL_CIPHER_TEXT_CHECK to your CFLAGS environment variable.

Timing Attack

This requires the adversary to precisely time the logical operations performed by a CPU or other device. By measuring these times the adversary is able to uncover the private data that was used to perform these operations. These kinds of attacks are even practical against well known, generally secure algorithms including RSA and ECC. Such  attacks are thwarted by making cryptographic operations run in a constant amount of time independent of the private key. More information on timing attacks can be found at: https://en.wikipedia.org/wiki/Timing_attack

Cache Attack

Modern processors perform speculative execution and can leave observable side effects due to execution of branches not taken. This can be in the form of memory access patterns which can be seen in the state of the memory cache. These patterns can indicate information about the private key. The adversary would use nefarious means to make a program access arbitrary locations in the program's memory space to get these patterns.  This attack can be mitigated by eliminating branching in cryptographic operations involving the private key.

RSA Blinding

This involves transforming the input just before the RSA private key operations using some random data. After the operation, the reverse of the transform is performed giving the desired output. This prevents an adversary from gaining knowledge about the private key as they don't know the random data that was used to determine the transform and therefore do not know the true input into the RSA private key operation.

Glitching

Glitching is when the adversary can feed in modified input data into an algorithm and then observe the error behavior to deduce information about the private key. This requires the adversary to have physical access and intimate knowledge of the software and hardware. They would modify the input into the algorithm by physically changing the values of the input in physical memory. This attack can be detected by copying the input to a separate buffer before a cryptographic operation and comparing the input buffer with that separate buffer after the cryptographic operation to ensure it has not changed.

Disabling Hardening

Generally speaking, you should always leave the “harden” flag enabled, however disabling it can give some performance gains. Here are some factors to consider whether it is appropriate to disable it:

  • Are you only dealing with public data and public keys?
  • Do you really need the performance gains?
  • Are you only doing off-line operations where cryptographic operation timings cannot be observed?
  • Are restrictions in place to ensure no physical access to the hardware?
  • Do you have very simple and audited application code and operating system to minimize nefarious code execution?
  • Did you minimize external interaction (ie network, user interface) to prevent nefarious inputs?
  • Do you sanity check all input data?

If you have any questions or run into any issues, contact us at facts@wolfssl.com, or call us at +1 425 245 8247.

wolfSSL + nuttX initial testing success!

wolfSSL is pleased to announce initial run-time testing of wolfCrypt + NuttX was successfully completed (Crypto algorithm tests and benchmarking) on both BL602 (RISC-V) and NUCLEO-L552ZE-Q (Cortex-M33) targets! wolfSSL engineers are now working on making a publically available drop-in for the NuttX-apps directory that users can take for a spin! The wolfSSL team is very excited about next steps which include but are not limited to:

  • Testing wolfCrypt post-quantum algorithms in NuttX
  • Testing client/server TLS 1.2 and TLS 1.3 connections in NuttX
  • Testing FIPS functionality in NuttX
  • Publishing benchmark results to our website

Console output from tests run on the RISC-V BL602 target:

NuttShell (NSH)

nsh> wolfcrypt_test

------------------------------------------------------------------------------

 wolfSSL version 5.5.4

------------------------------------------------------------------------------

error    test passed!

MEMORY   test passed!

base64   test passed!

asn      test passed!

RANDOM   test passed!

MD5      test passed!

SHA      test passed!

SHA-256  test passed!

Hash     test passed!

HMAC-MD5 test passed!

HMAC-SHA test passed!

HMAC-SHA256 test passed!

DES      test passed!

DES3     test passed!

AES      test passed!

AES192   test passed!

AES256   test passed!

RSA      test passed!

DH       test passed!

PWDBASED test passed!

ECC      test passed!

ECC buffer test passed!

logging  test passed!

time test passed!

mutex    test passed!

memcb    test passed!

Test complete

Exiting main with return code: 0

Have any other ideas or Proof of Concepts you would like us to consider? If you have any questions or run into any issues, contact us at facts@wolfssl.com, or call us at +1 425 245 8247.

 

Heard of NuttX?

Heard of NuttX?  Fresh out of the Apache incubator, it’s a small RTOS with a focus on POSIX and ANSI standards compliance, scales from 8 to 64-bit microcontrollers, is extensively documented, ported to many platforms, and is very easy to get started with!

 Here at wolfSSL we are hard at work testing wolfSSL with NuttX.  The flexible, efficient nature of NuttX makes it a natural fit for a lean, embedded SSL/TLS implementation like wolfSSL.  

Interested?  Let us know!

If you have any questions or run into any issues, contact us at facts@wolfssl.com, or call us at +1 425 245 8247.

 

wolfSSH v1.4.12 Release

wolfSSL are proud to announce a new incremental update to wolfSSH: v1.4.12!

In this release, we have wolfSSHD running. It seamlessly fits in where other SSHDs are, and is able to parse and make use of existing sshd_config files that are in place.

We are also proud to announce that wolfSSH builds and runs in the Green Hills Software INTEGRITY environment. It takes advantage of INTEGRITY’s POSIX API. You can run a shell through it, or upload files to the local filesystem using SFTP.

For the cutting edge, wolfSSH adds Hybrid ECDH-P256 Kyber-Level1 for post-quantum hybrid key exchange.

The release information from the change log is reposted below:

New Feature Additions and Improvements

  • Support for Green Hills Software's INTEGRITY
  • wolfSSHd Release (https://github.com/wolfSSL/wolfssh/pull/453 rounds off testing and additions)
  • Support for RFC 6187, using X.509 Certificates as public keys
  • OCSP and CRL checking for X.509 Certificates (uses wolfSSL CertManager)
  • Add callback to the server for reporting userauth result
  • FPKI profile checking support
  • chroot jailing for SFTP in wolfSSHd
  • Permission level changes in wolfSSHd
  • Add Hybrid ECDH-P256 Kyber-Level1
  • Multiple server keys
  • Makefile updates
  • Remove dependency on wolfSSL being built with public math enabled

Fixes

  • Fixes for compiler complaints using GHS compiler
  • Fixes for compiler complaints using GCC 4.0.2
  • Fixes for the directory path cleanup function for SFTP
  • Fixes for SFTP directory listing when on Windows
  • Fixes for large file transfers with SFTP
  • Fixes for port forwarding
  • Fix for building with QNX
  • Fix for the wolfSSHd grace time alarm
  • Fixes for Yocto builds
  • Fixes for issues found with fuzzing

Vulnerabilities

  • The vulnerability fixed in wolfSSH v1.4.8 finally issued CVE-2022-32073

If you have any questions or run into any issues, contact us at facts@wolfssl.com, or call us at +1 425 245 8247.

wolfSSL 5.5.4 Release!

Merry Christmas! The Christmas release of wolfSSL is here, version 5.5.4! This includes some minor feature additions, QUIC related changes for HAProxy use, port to the MAXQ hardware, improvements in performance, as well as additional enhancements and fixes. In this development cycle we also did testing of using wolfSSL with NuttX, and wolfSSL is ready to go for any projects looking for TLS / cryptography with NuttX.

Here are some of the key new features  we added to this new version.

New Feature Additions

  •  QUIC related changes for HAProxy integration and config option
  •  Support for Analog Devices MAXQ1080 and MAXQ1065
  •  Testing and build of wolfSSL with NuttX
  •  New software based entropy gatherer with configure option --enable-entropy-memuse
  •  NXP SE050 feature expansion and fixes, adding in RSA support and conditional compile of AES and CMAC
  •  Support for multi-threaded sniffer

The full list of changes can be found in the ChangeLog.md bundled with wolfSSL or on the website www.wolfssl.com.

Visit our download page or https://github.com/wolfssl for downloading the bundle. If you have any questions or run into any issues, contact us at facts@wolfssl.com, or call us at +1 425 245 8247.

HPKE support in wolfCrypt

HPKE support in wolfCrypt

HPKE (Hybrid Public Key Encryption) is a key encapsulation and encryption standard that allows two parties to derive a common secret and encrypt/decrypt messages using that common secret (https://www.ietf.org/archive/id/draft-irtf-cfrg-hpke-12.txt)

 HPKE has three steps in single-shot mode: 

  1. Key encapsulation (KEM) - ECC P256, P384, P521 or X25519
  2. Hash based Key Derivation (HKDF) - SHA2-256, SHA2-384, SHA2-512
  3. Authenticated Encryption with Associated Data (AEAD). AES-GCM 128/256 bit

Here is an example of how HPKE is used: https://gist.github.com/jpbland1/b2a1c46bc934fd8ee0dc4d148a8b9eab

The `Hpke` struct is used for the HPKE operations and we initialize it with our KEM, KDF and AEAD algorithms using `wc_HpkeInit`. Here we're using X25519, SHA256 and AES128. Then we need to generate keypairs to use, with the `ephemeralKey` being used by the client to seal messages and the `receiverKey` being used by the server to open them. They're both generated using `wc_HpkeGenerateKeyPair` and have a type of `void*` because they can actually be one of many types depending on the KEM algorithm chosen, which wolfCrypt takes care of internally. The client then seals our message using `wc_HpkeSealBase` which takes the client’s private key, the server’s public key, an optional info field, an optional AAD field, the message to encrypt `start_text` and the buffer to put the encrypted message into `ciphertext`. NOTE that `ciphertext` MUST be 16 bytes longer than the message we're trying to encrypt to store the AEAD tag needed to decrypt it. `wc_HpkeSerializePublicKey` will serialize an HPKE public key into a bytestring so it can be shared with the other party. Keys can later be deserialized using `wc_HpkeDeserializePublicKey`. These functions should be used to share the KEM public keys between client and server. Then for the server to decrypt, `wc_HpkeOpenBase` takes the `receiverKey`, the serialized public `ephemeralKey`, an optional info field, an optional AAD field, the ciphertext and tag to decrypt and the buffer to store the decrypted message. When finished the `plaintext` buffer will have the same data in it as the original `start_text` buffer. To free the keys when we're done using them we call `wc_HpkeFreeKey` with the `kem` and key.

Support for ECH and HPKE was added in PR https://github.com/wolfSSL/wolfssl/pull/5623

If you have any questions or run into any issues, contact us at facts@wolfssl.com, or call us at +1 425 245 8247.

 

Encrypted Client Hello (ECH) now supported in wolfSSL

ECH (Encrypted Client Hello) is a draft extension for TLS 1.3 that enables a client to encrypt its client_hello in the TLS handshake to prevent leaking sensitive metadata that is sent in the clear during the normal TLS handshake. ECH was originally proposed as ESNI (Encrypted Server Name Indication), since the server name indication is one of the sensitive fields that is visible to a passive observer during the handshake, but was later renamed since it covers the entire Client Hello. ECH uses HPKE (Hybrid Public Key Encryption) to derive a shared secret and encrypt the client_hello.

ECH works by making an inner Client Hello and an outer Client Hello. The outer hello has all sensitive metadata removed and includes a new TLS extension called ECH. The inner hello contains all the sensitive information and is encrypted using HPKE and then placed into the outer hello as the ECH extension. The client sends the outer hello and the server picks up on the use of ECH and decrypts the inner hello using its HPKE key.

Here is an example of how ECH is used:

https://gist.github.com/jpbland1/ad46617fcc40934b252ce031c7aa5969

In this example we connect to the Cloudflare server that has been setup to test different TLS and security settings and then call `wolfSSL_GetEchConfigs` to get the `retry_configs`. We then make a new SSL object, call `wolfSSL_SetEchConfigs` to apply the retry configs and then connect using ECH. We do this connect and reconnect process to get the `retry_configs` by sending what's called a GREASE ECH or a dummy ECH which is sent out in the absence of a set ECH. We can skip this step if we retrieve the ECH configs from a website's DNS records, but DNS is out of the scope of this example. Once we have the ECH configs set we can connect to and use the ssl connection like normal, here we send an http request to `/cdn-cgi/trace/ HTTP/1.1\r\n`, which will send us back information about our TLS connection. In the response that prints we will see `sni=encrypted`, which means that ECH is working.

Support for ECH was added in PR https://github.com/wolfSSL/wolfssl/pull/5623

If you have any questions or run into any issues, contact us at facts@wolfssl.com, or call us at +1 425 245 8247.

 

wolfSSL on Softcore RISC-V

In our never-ending quest to have wolfSSL supported and running on all platforms, everywhere, for everyone, we are proud to announce we are now supporting Softcore RISC-V Environments.

What is a Softcore RISC-V CPU? We’re glad you asked! Softcore means the electronics are created on a “soft” and reusable FPGA instead of the one-time, hard silicon manufacturing process. The RISC-V is of course open source; This allows anyone to build their own CPU and not pay any license fees for architecture or buy expensive proprietary development software. Silicon fabrication is expensive and time consuming for hardcore CPUs. 

Open-source toolchains such as those at YosysHQ allow literally anyone with a modern computer to build nearly anything imaginable on the “soft” fabric of an FPGA. This includes a full-blown CPU!  Anyone from the hobbyist building a CPU literally at the kitchen table at home to the most skilled development engineers developing next-generation, state-of-the-art custom CPUs in secret labs can use RISC-V technology. We’re there with you to help secure your data and connections to the outside world.

There are several different open-source RISC-V CPU projects out there. The one we’ve chosen to test with our wolfSSL code targets the Lattice Semiconductor ECP5-85F chip, specifically the FPGA on the Radiona ULX3S from our friends over at Crowd Supply. The soft RISC-V CPU is the Wren6991/Hazard3. This project was chosen as a test environment due to its relative grace and simplicity, as well as including a soft JTAG.

Are you interested in building your own custom CPU with wolfSSL? If you have any questions or run into any issues, contact us at facts@wolfssl.com, or call us at +1 425 245 8247.

Rocky Linux FIPS

Are you interested in utilizing FIPS 140-2 cryptography on the Rocky Linux™ platform?  wolfSSL will soon be adding the Rocky Linux Operating Environment to our wolfCrypt FIPS certificate.  Let us know your exact hardware to ensure we add the configuration you need.  The wolfCrypt FIPS module can be used with wolfSSL, wolfSSH, third party Open Source projects like nginx and curl, and even as an OpenSSL engine.

If you have any questions or run into any issues, contact us at facts@wolfssl.com, or call us at +1 425 245 8247.

 

DHE Vulnerability of CVE 2022-40735

Customers have asked about CVE 2022-40735 (https://nvd.nist.gov/vuln/detail/CVE-2022-40735) and whether they are vulnerable as users of wolfSSL. The short is answer is: No. But, there are ways that you can put yourself at risk. Let’s delve into the CVE and how best to protect yourself from attacks like this.

First of all, a description of the CVE is in order to be able to have a proper discussion. The attack centres on the use of DHE in a protocol like TLS where the server uses a large private or large parameters. The actual attack is not clear as we haven’t seen the corresponding paper at time of writing. Despite a minimal description, we can make some good security decisions to protect ourselves.

The attack has a client sending one or more messages to the server to initiate a DHE key exchange. In TLS 1.2, this means the client starts a handshake and negotiates a DHE cipher suite. In TLS 1.3, the client sends a DH key share and only lists support for DH named groups (not named curves). The attack come from the client having to do very little work while the server needs to generate a key pair.

In TLS 1.2, the server generates a key pair first and sends the DH parameters and public key to the client. The client at this point can drop the connection and start again. In TLS 1.3 the client can send the same key share over and over again and drop the connection when the server sends its public DH key.

The amount of work the server has to perform for DHE can be quite large. DHE operations are known to be quite slow and there are ways it can be even slower.

Generating a key pair for the exchange involves generating a random private key and calculating a public key. A private key can be as big as the order - the number of distinct values that can be reached by exponentiating the generator (g). The order is about the same size as the prime modulus.

Wisdom past was that you generate a private key large enough to cover the order. But this is a waste! A 2048-bit DH key has only 112 bits of security. Given that it is very hard computationally to find private key from public key, it turns out 224-bits of private key will suffice. Modular exponentiation with a 2048-bit exponent (private key) will be about 8 times slower than with a 224-bit exponent!

wolfSSL will use a small, but secure, private key when the order is not known and when using named groups.

The CVE describes the attack as a Denial of Service (DoS). That is, the server is too busy generating DH keys to do anything else. But how powerful is the server? How many connections can it handle concurrently? These are questions that you should answer based on your setup.

If a server thread is only expected to handle tens of connections a seconds and the number of DHE operations per second is significantly more, then there is no issue! But if the number of DHE operations per second is close to the required number of connections then some changes need to be made.

Another part of the attack is forcing the server to use larger parameters. For reasons of enhanced security, a server may configured to be able to use the named groups of 2048, 3072 and 4096 bits. On a modern Intel x64 server, say, 4000 2048-bit DHE key generations can be completed in a second. But for 3072-bit DHE only 2000 and for 4096-bit key generations only 1000. Therefore understanding how many connections you want to support compared to how many DHE operations that can be performed per second is important.

So using appropriate sized parameters is an important mitigation if you are to use DHE cipher suites with TLS. Ensure the server is only configured to support parameters of a size that you can handle.

An alternative mitigation is to not use DHE in your TLS handshakes. ECDHE is quite commonly supported and popular. Using X25519 can be 5 times faster than 2048-bit DHE.

There are other mitigations that involve detecting and protecting against DoS attacks. One mechanism is to detect malicious clients and block them or time them out. These protections are considered best practice and should be implemented even when not protecting against this CVE.

In summary, wolfSSL is not vulnerable to the issue of long private keys in DHE key generation as described in CVE 2022-40735. Consider carefully, though, the size of the DHE parameters you allow on you server. The relative performance of DHE operations to connection requirements may mean you should be switching to ECDHE anyway.

If you have any questions or run into any issues, contact us at facts@wolfssl.com, or call us at +1 425 245 8247.

Posts navigation

1 2 3 5 6 7 8 9 10 11 22 23 24