Commit Graph
33 Commits
Author SHA1 Message Date
Tobias Brunner 374b17fe88 openssl: Fix 'const' issues that came up with OpenSSL 4 2026-05-06 10:46:43 +02:00
Tobias Brunner 528e5f07c3 openssl: Use functions for ASN.1 struct members hidden in OpenSSL 4
According to the docs, most ASN.1 types are just typedefs of ASN1_STRING.
2026-05-06 10:46:43 +02:00
Thomas Egerer 82c01b7060 openssl: Use openssl_i2chunk when creating ASN.1 chunks
Using the return value of i2d_* directly as input of chunk_alloc imposes
the risk of creating an invalid chunk when the return value of the i2d_*
function is -1. The openssl_i2chunk macro is meant to avoid this.

Signed-off-by: Thomas Egerer <[email protected]>
2026-05-06 10:46:43 +02:00
Tobias Brunner 05807b1b1b openssl: Handle EdDSA keys from engines special again
Fixes: 052a939553 ("openssl: Add support for Ed25519 via AWS-LC")
2026-04-02 08:17:05 +02:00
Tobias Brunner 052a939553 openssl: Add support for Ed25519 via AWS-LC 2025-08-21 16:44:01 +02:00
Tobias Brunner 135ed6aada openssl: Simplify wrapping private key objects 2025-08-21 16:11:13 +02:00
Gerardo Ravago 44e241fccc openssl: Handle BoringSSL-style ASN1_INTEGERs in cert serials
OpenSSL stores the serial number for an X509 certificate as an
`ASN1_INTEGER` type. Within BoringSSL (and AWS-LC), the library
represents the value of zero as an empty array [1] which is different
from OpenSSL which represents it as the 1-byte array [0x00]. Though the
value of zero for the certificate serial number is illegal under
X.509 [2], we need to handle/encode it consistently within strongSwan.
From 18082ce2b0 ("certificates: Retrieve serial numbers in canonical
form"), we infer that the canonical representation of the zero serial
is [0x00]. To do this, we introduce `openssl_asn1_int2chunk` to
complement the existing string version that allows us to handle the
special case for zero instead of always returning a reference to the
library-dependent encodings.

References strongswan/strongswan#1907
Closes strongswan/strongswan#2138

[1] https://github.com/google/boringssl/commit/bdc35b63617f78037768f4897d8835696f02181a
[2] https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.2
2024-03-05 08:51:16 +01:00
Tobias Brunner c58ba0cb9f openssl: Remove unused openssl_hash_chunk() helper
Was used by the ECDSA implementation before 293a912c7d ("openssl: Fixes
for ECDSA with OpenSSL 3.0").
2022-10-05 18:15:26 +02:00
Tobias Brunner 48e9267d7a cred-encoding: Avoid potential use after free when caching encodings
The pattern currently is to call get_cache(), generate the encoding
if that failed and then store it with cache().  The latter adopts the
passed encoding and frees any stored encoding.  However, the latter means
that if two threads concurrently fail to get a cached encoding and then
both generate and store one, one of the threads might use an encoding
that was freed by the other thread.

Since encodings are not expected to change, we can avoid this issue by
not replacing an existing cache entry and instead return that (while
freeing the passed value instead of the cached one).

Closes strongswan/strongswan#1231
2022-09-20 09:53:13 +02:00
Tobias Brunner 19ef2aec15 Update copyright headers after acquisition by secunet 2022-06-28 10:22:56 +02:00
Tobias Brunner 293a912c7d openssl: Fixes for ECDSA with OpenSSL 3.0 2022-04-14 19:05:44 +02:00
Tobias Brunner 36cf74f5d9 openssl: Fixes for DH with OpenSSL 3.0
While we could assign the DH object to a EVP_PKEY object, this won't work
with BoringSSL as it doesn't seem to support EVP_PKEY_derive() for DH.
2022-04-14 19:05:44 +02:00
Tobias Brunner 1c1213f4b6 openssl: Move shared secret calculation to get_shared_secret()
This is a change from the multi-KE branch.
2022-04-14 19:05:44 +02:00
Tobias Brunner 5fdc979770 openssl: Extract helper function to derive a shared DH secret 2021-01-20 17:53:35 +01:00
Thomas Egerer cf18951efd openssl: Make some additional arguments const
Related to openssl 1.1.x changes.

Signed-off-by: Thomas Egerer <[email protected]>
2019-12-11 13:09:04 +01:00
Tobias Brunner 8b4c2a1d8e openssl: Fix some const issues with OpenSSL 1.1.0 2018-10-31 15:50:36 +01:00
Tobias Brunner fd3947d9e5 openssl: Don't use functions deprecated with OpenSSL 1.1.0 2018-10-31 15:50:36 +01:00
Tobias Brunner 1b67166921 Unify format of HSR copyright statements 2018-05-23 16:32:53 +02:00
Tobias Brunner 375a5ed240 openssl: Make some utilities take const BIGNUM pointers 2016-06-29 11:09:37 +02:00
Tobias Brunner faa904fb0b openssl: Fix mapping from ASN1 to chunk_t with OpenSSL 1.1.0
ASN1_OBJECT is now opaque.
2016-06-29 11:09:37 +02:00
Tobias Brunner 77df573a95 openssl: Use proper EVP macro to determine size of a hash 2016-04-15 10:32:52 +02:00
Tobias Brunner 5f18e2c371 openssl: Explicitly include openssl/bn.h
If OpenSSL is compiled with OPENSSL_NO_DEPRECATED some of the headers
we include don't include openssl/bn.h anymore.  Therefore, we have to
explicitly include it ourselves where we use BN_* functions.

Fixes #1113.
2015-09-16 11:57:52 +02:00
Tobias Brunner b5cc7053c8 openssl: Add helper function to convert BIGNUMs to chunks 2013-09-13 15:23:49 +02:00
Tobias Brunner f05b427265 Moved debug.[ch] to utils folder 2012-10-24 16:00:51 +02:00
Martin Willi 24fa80ac91 Fixed compiler warnings in openssl plugin 2011-09-07 14:23:27 +02:00
Martin Willi 5728c6aa7e Implemented X.509 certificate reading using OpenSSL 2010-05-21 16:25:51 +02:00
Martin Willi 7daf5226b7 removed trailing spaces ([[:space:]]+$) 2009-09-04 13:46:09 +02:00
Martin Willi b12c6d163d do openssl fingerprinting/encoding directly, openssl provides all functions 2009-08-27 09:58:38 +02:00
Martin Willi 083142c4a0 encoding public EC keys is not really possible without subjectPublicKeyInfo 2009-08-26 16:15:38 +02:00
Martin Willi e35c3e2a03 updated openssl plugin to new private/public key API, use encoder framework 2009-08-26 11:23:52 +02:00
Andreas Steffen 21863d6361 ecp_x_coordinate only option allows ECP interoperability with MS Windows 2009-07-06 08:47:18 +02:00
Tobias Brunner 8c5d72cd0b removing svn keyword $Id$ from all files 2009-04-30 13:19:35 +00:00
Tobias Brunner ea0823dffd ECDSA with OpenSSL 2008-06-10 09:08:27 +00:00