Update BoringSSL to 2042972e8458833714bce23386931b1c79978439 (#97)

This commit is contained in:
Cory Benfield 2021-12-09 11:12:34 +00:00 committed by GitHub
parent bd5abc2a12
commit 9c53b7a758
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 92 additions and 27 deletions

View File

@ -20,7 +20,7 @@
// Sources/CCryptoBoringSSL directory. The source repository is at
// https://boringssl.googlesource.com/boringssl.
//
// BoringSSL Commit: 3a667d10e94186fd503966f5638e134fe9fb4080
// BoringSSL Commit: 2042972e8458833714bce23386931b1c79978439
import PackageDescription

View File

@ -745,6 +745,22 @@ void ERR_add_error_dataf(const char *format, ...) {
err_set_error_data(buf);
}
void ERR_set_error_data(char *data, int flags) {
if (!(flags & ERR_FLAG_STRING)) {
// We do not support non-string error data.
assert(0);
return;
}
if (flags & ERR_FLAG_MALLOCED) {
err_set_error_data(data);
} else {
char *copy = OPENSSL_strdup(data);
if (copy != NULL) {
err_set_error_data(copy);
}
}
}
int ERR_set_mark(void) {
ERR_STATE *const state = err_get_state();

View File

@ -359,6 +359,18 @@ static int probable_prime_dh(BIGNUM *rnd, int bits, const BIGNUM *add,
static int probable_prime_dh_safe(BIGNUM *rnd, int bits, const BIGNUM *add,
const BIGNUM *rem, BN_CTX *ctx);
BN_GENCB *BN_GENCB_new(void) {
BN_GENCB *callback = OPENSSL_malloc(sizeof(BN_GENCB));
if (callback == NULL) {
OPENSSL_PUT_ERROR(BN, ERR_R_MALLOC_FAILURE);
return NULL;
}
OPENSSL_memset(callback, 0, sizeof(BN_GENCB));
return callback;
}
void BN_GENCB_free(BN_GENCB *callback) { OPENSSL_free(callback); }
void BN_GENCB_set(BN_GENCB *callback,
int (*f)(int event, int n, struct bn_gencb_st *),
void *arg) {

View File

@ -930,6 +930,8 @@ int RSA_private_transform(RSA *rsa, uint8_t *out, const uint8_t *in,
int RSA_flags(const RSA *rsa) { return rsa->flags; }
int RSA_test_flags(const RSA *rsa, int flags) { return rsa->flags & flags; }
int RSA_blinding_on(RSA *rsa, BN_CTX *ctx) {
return 1;
}

View File

@ -179,6 +179,16 @@ struct X509_req_st {
CRYPTO_refcount_t references;
} /* X509_REQ */;
struct x509_revoked_st {
ASN1_INTEGER *serialNumber;
ASN1_TIME *revocationDate;
STACK_OF(X509_EXTENSION) /* optional */ *extensions;
// Set up if indirect CRL
STACK_OF(GENERAL_NAME) *issuer;
// Revocation reason
int reason;
} /* X509_REVOKED */;
typedef struct {
ASN1_INTEGER *version;
X509_ALGOR *sig_alg;

View File

@ -116,12 +116,12 @@ int X509_CRL_print(BIO *out, X509_CRL *x)
for (i = 0; i < sk_X509_REVOKED_num(rev); i++) {
r = sk_X509_REVOKED_value(rev, i);
BIO_printf(out, " Serial Number: ");
i2a_ASN1_INTEGER(out, r->serialNumber);
i2a_ASN1_INTEGER(out, X509_REVOKED_get0_serialNumber(r));
BIO_printf(out, "\n Revocation Date: ");
ASN1_TIME_print(out, r->revocationDate);
ASN1_TIME_print(out, X509_REVOKED_get0_revocationDate(r));
BIO_printf(out, "\n");
X509V3_extensions_print(out, "CRL entry extensions",
r->extensions, 0, 8);
X509_REVOKED_get0_extensions(r), 0, 8);
}
X509_signature_print(out, sig_alg, signature);

View File

@ -116,16 +116,8 @@ int X509_CRL_set1_nextUpdate(X509_CRL *x, const ASN1_TIME *tm)
int X509_CRL_sort(X509_CRL *c)
{
size_t i;
X509_REVOKED *r;
/*
* sort the data so it will be written in serial number order
*/
/* Sort the data so it will be written in serial number order. */
sk_X509_REVOKED_sort(c->crl->revoked);
for (i = 0; i < sk_X509_REVOKED_num(c->crl->revoked); i++) {
r = sk_X509_REVOKED_value(c->crl->revoked, i);
r->sequence = i;
}
c->crl->enc.modified = 1;
return 1;
}

View File

@ -1 +1 @@
This directory is derived from BoringSSL cloned from https://boringssl.googlesource.com/boringssl at revision 3a667d10e94186fd503966f5638e134fe9fb4080
This directory is derived from BoringSSL cloned from https://boringssl.googlesource.com/boringssl at revision 2042972e8458833714bce23386931b1c79978439

View File

@ -658,6 +658,14 @@ struct bn_gencb_st {
int (*callback)(int event, int n, struct bn_gencb_st *);
};
// BN_GENCB_new returns a newly-allocated |BN_GENCB| object, or NULL on
// allocation failure. The result must be released with |BN_GENCB_free| when
// done.
OPENSSL_EXPORT BN_GENCB *BN_GENCB_new(void);
// BN_GENCB_free releases memory associated with |callback|.
OPENSSL_EXPORT void BN_GENCB_free(BN_GENCB *callback);
// BN_GENCB_set configures |callback| to call |f| and sets |callout->arg| to
// |arg|.
OPENSSL_EXPORT void BN_GENCB_set(BN_GENCB *callback,

View File

@ -314,6 +314,8 @@
#define BN_CTX_new BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BN_CTX_new)
#define BN_CTX_start BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BN_CTX_start)
#define BN_GENCB_call BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BN_GENCB_call)
#define BN_GENCB_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BN_GENCB_free)
#define BN_GENCB_new BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BN_GENCB_new)
#define BN_GENCB_set BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BN_GENCB_set)
#define BN_MONT_CTX_copy BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BN_MONT_CTX_copy)
#define BN_MONT_CTX_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BN_MONT_CTX_free)
@ -872,6 +874,7 @@
#define ERR_remove_thread_state BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ERR_remove_thread_state)
#define ERR_restore_state BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ERR_restore_state)
#define ERR_save_state BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ERR_save_state)
#define ERR_set_error_data BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ERR_set_error_data)
#define ERR_set_mark BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ERR_set_mark)
#define EVP_AEAD_CTX_aead BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_AEAD_CTX_aead)
#define EVP_AEAD_CTX_cleanup BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_AEAD_CTX_cleanup)
@ -1570,6 +1573,7 @@
#define RSA_sign_pss_mgf1 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RSA_sign_pss_mgf1)
#define RSA_sign_raw BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RSA_sign_raw)
#define RSA_size BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RSA_size)
#define RSA_test_flags BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RSA_test_flags)
#define RSA_up_ref BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RSA_up_ref)
#define RSA_verify BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RSA_verify)
#define RSA_verify_PKCS1_PSS_mgf1 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RSA_verify_PKCS1_PSS_mgf1)

View File

@ -319,6 +319,8 @@
#define _BN_CTX_new BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BN_CTX_new)
#define _BN_CTX_start BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BN_CTX_start)
#define _BN_GENCB_call BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BN_GENCB_call)
#define _BN_GENCB_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BN_GENCB_free)
#define _BN_GENCB_new BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BN_GENCB_new)
#define _BN_GENCB_set BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BN_GENCB_set)
#define _BN_MONT_CTX_copy BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BN_MONT_CTX_copy)
#define _BN_MONT_CTX_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BN_MONT_CTX_free)
@ -877,6 +879,7 @@
#define _ERR_remove_thread_state BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ERR_remove_thread_state)
#define _ERR_restore_state BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ERR_restore_state)
#define _ERR_save_state BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ERR_save_state)
#define _ERR_set_error_data BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ERR_set_error_data)
#define _ERR_set_mark BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ERR_set_mark)
#define _EVP_AEAD_CTX_aead BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_AEAD_CTX_aead)
#define _EVP_AEAD_CTX_cleanup BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_AEAD_CTX_cleanup)
@ -1575,6 +1578,7 @@
#define _RSA_sign_pss_mgf1 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RSA_sign_pss_mgf1)
#define _RSA_sign_raw BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RSA_sign_raw)
#define _RSA_size BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RSA_size)
#define _RSA_test_flags BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RSA_test_flags)
#define _RSA_up_ref BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RSA_up_ref)
#define _RSA_verify BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RSA_verify)
#define _RSA_verify_PKCS1_PSS_mgf1 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RSA_verify_PKCS1_PSS_mgf1)

View File

@ -183,6 +183,11 @@ OPENSSL_EXPORT uint32_t ERR_get_error_line(const char **file, int *line);
// can be printed. This is always set if |data| is non-NULL.
#define ERR_FLAG_STRING 1
// ERR_FLAG_MALLOCED is passed into |ERR_set_error_data| to indicate that |data|
// was allocated with |OPENSSL_malloc|. It is never returned from
// |ERR_get_error_line_data|.
#define ERR_FLAG_MALLOCED 2
// ERR_get_error_line_data acts like |ERR_get_error_line|, but also returns the
// error-specific data pointer and flags. The flags are a bitwise-OR of
// |ERR_FLAG_*| values. The error-specific data is owned by the error queue
@ -408,9 +413,10 @@ OPENSSL_EXPORT char *ERR_error_string(uint32_t packed_error, char *buf);
// ERR_GET_FUNC returns zero. BoringSSL errors do not report a function code.
#define ERR_GET_FUNC(packed_error) 0
// ERR_TXT_STRING is provided for compatibility with code that assumes that
// it's using OpenSSL.
// ERR_TXT_* are provided for compatibility with code that assumes that it's
// using OpenSSL.
#define ERR_TXT_STRING ERR_FLAG_STRING
#define ERR_TXT_MALLOCED ERR_FLAG_MALLOCED
// Private functions.
@ -444,6 +450,17 @@ OPENSSL_EXPORT void ERR_add_error_data(unsigned count, ...);
OPENSSL_EXPORT void ERR_add_error_dataf(const char *format, ...)
OPENSSL_PRINTF_FORMAT_FUNC(1, 2);
// ERR_set_error_data sets the data on the most recent error to |data|, which
// must be a NUL-terminated string. |flags| must contain |ERR_FLAG_STRING|. If
// |flags| contains |ERR_FLAG_MALLOCED|, this function takes ownership of
// |data|, which must have been allocated with |OPENSSL_malloc|. Otherwise, it
// saves a copy of |data|.
//
// Note this differs from OpenSSL which, when |ERR_FLAG_MALLOCED| is unset,
// saves the pointer as-is and requires it remain valid for the lifetime of the
// address space.
OPENSSL_EXPORT void ERR_set_error_data(char *data, int flags);
// ERR_NUM_ERRORS is one more than the limit of the number of errors in the
// queue.
#define ERR_NUM_ERRORS 16

View File

@ -615,6 +615,9 @@ OPENSSL_EXPORT void *RSA_get_ex_data(const RSA *rsa, int idx);
// constants.
OPENSSL_EXPORT int RSA_flags(const RSA *rsa);
// RSA_test_flags returns the subset of flags in |flags| which are set in |rsa|.
OPENSSL_EXPORT int RSA_test_flags(const RSA *rsa, int flags);
// RSA_blinding_on returns one.
OPENSSL_EXPORT int RSA_blinding_on(RSA *rsa, BN_CTX *ctx);

View File

@ -249,17 +249,6 @@ DEFINE_STACK_OF(X509_TRUST)
(ASN1_STRFLGS_ESC_CTRL | ASN1_STRFLGS_ESC_MSB | XN_FLAG_SEP_MULTILINE | \
XN_FLAG_SPC_EQ | XN_FLAG_FN_LN | XN_FLAG_FN_ALIGN)
struct x509_revoked_st {
ASN1_INTEGER *serialNumber;
ASN1_TIME *revocationDate;
STACK_OF(X509_EXTENSION) /* optional */ *extensions;
// Set up if indirect CRL
STACK_OF(GENERAL_NAME) *issuer;
// Revocation reason
int reason;
int sequence; // load sequence
};
DEFINE_STACK_OF(X509_REVOKED)
DECLARE_STACK_OF(GENERAL_NAMES)

View File

@ -311,6 +311,8 @@
%xdefine _BN_CTX_new _ %+ BORINGSSL_PREFIX %+ _BN_CTX_new
%xdefine _BN_CTX_start _ %+ BORINGSSL_PREFIX %+ _BN_CTX_start
%xdefine _BN_GENCB_call _ %+ BORINGSSL_PREFIX %+ _BN_GENCB_call
%xdefine _BN_GENCB_free _ %+ BORINGSSL_PREFIX %+ _BN_GENCB_free
%xdefine _BN_GENCB_new _ %+ BORINGSSL_PREFIX %+ _BN_GENCB_new
%xdefine _BN_GENCB_set _ %+ BORINGSSL_PREFIX %+ _BN_GENCB_set
%xdefine _BN_MONT_CTX_copy _ %+ BORINGSSL_PREFIX %+ _BN_MONT_CTX_copy
%xdefine _BN_MONT_CTX_free _ %+ BORINGSSL_PREFIX %+ _BN_MONT_CTX_free
@ -869,6 +871,7 @@
%xdefine _ERR_remove_thread_state _ %+ BORINGSSL_PREFIX %+ _ERR_remove_thread_state
%xdefine _ERR_restore_state _ %+ BORINGSSL_PREFIX %+ _ERR_restore_state
%xdefine _ERR_save_state _ %+ BORINGSSL_PREFIX %+ _ERR_save_state
%xdefine _ERR_set_error_data _ %+ BORINGSSL_PREFIX %+ _ERR_set_error_data
%xdefine _ERR_set_mark _ %+ BORINGSSL_PREFIX %+ _ERR_set_mark
%xdefine _EVP_AEAD_CTX_aead _ %+ BORINGSSL_PREFIX %+ _EVP_AEAD_CTX_aead
%xdefine _EVP_AEAD_CTX_cleanup _ %+ BORINGSSL_PREFIX %+ _EVP_AEAD_CTX_cleanup
@ -1567,6 +1570,7 @@
%xdefine _RSA_sign_pss_mgf1 _ %+ BORINGSSL_PREFIX %+ _RSA_sign_pss_mgf1
%xdefine _RSA_sign_raw _ %+ BORINGSSL_PREFIX %+ _RSA_sign_raw
%xdefine _RSA_size _ %+ BORINGSSL_PREFIX %+ _RSA_size
%xdefine _RSA_test_flags _ %+ BORINGSSL_PREFIX %+ _RSA_test_flags
%xdefine _RSA_up_ref _ %+ BORINGSSL_PREFIX %+ _RSA_up_ref
%xdefine _RSA_verify _ %+ BORINGSSL_PREFIX %+ _RSA_verify
%xdefine _RSA_verify_PKCS1_PSS_mgf1 _ %+ BORINGSSL_PREFIX %+ _RSA_verify_PKCS1_PSS_mgf1
@ -3155,6 +3159,8 @@
%xdefine BN_CTX_new BORINGSSL_PREFIX %+ _BN_CTX_new
%xdefine BN_CTX_start BORINGSSL_PREFIX %+ _BN_CTX_start
%xdefine BN_GENCB_call BORINGSSL_PREFIX %+ _BN_GENCB_call
%xdefine BN_GENCB_free BORINGSSL_PREFIX %+ _BN_GENCB_free
%xdefine BN_GENCB_new BORINGSSL_PREFIX %+ _BN_GENCB_new
%xdefine BN_GENCB_set BORINGSSL_PREFIX %+ _BN_GENCB_set
%xdefine BN_MONT_CTX_copy BORINGSSL_PREFIX %+ _BN_MONT_CTX_copy
%xdefine BN_MONT_CTX_free BORINGSSL_PREFIX %+ _BN_MONT_CTX_free
@ -3713,6 +3719,7 @@
%xdefine ERR_remove_thread_state BORINGSSL_PREFIX %+ _ERR_remove_thread_state
%xdefine ERR_restore_state BORINGSSL_PREFIX %+ _ERR_restore_state
%xdefine ERR_save_state BORINGSSL_PREFIX %+ _ERR_save_state
%xdefine ERR_set_error_data BORINGSSL_PREFIX %+ _ERR_set_error_data
%xdefine ERR_set_mark BORINGSSL_PREFIX %+ _ERR_set_mark
%xdefine EVP_AEAD_CTX_aead BORINGSSL_PREFIX %+ _EVP_AEAD_CTX_aead
%xdefine EVP_AEAD_CTX_cleanup BORINGSSL_PREFIX %+ _EVP_AEAD_CTX_cleanup
@ -4411,6 +4418,7 @@
%xdefine RSA_sign_pss_mgf1 BORINGSSL_PREFIX %+ _RSA_sign_pss_mgf1
%xdefine RSA_sign_raw BORINGSSL_PREFIX %+ _RSA_sign_raw
%xdefine RSA_size BORINGSSL_PREFIX %+ _RSA_size
%xdefine RSA_test_flags BORINGSSL_PREFIX %+ _RSA_test_flags
%xdefine RSA_up_ref BORINGSSL_PREFIX %+ _RSA_up_ref
%xdefine RSA_verify BORINGSSL_PREFIX %+ _RSA_verify
%xdefine RSA_verify_PKCS1_PSS_mgf1 BORINGSSL_PREFIX %+ _RSA_verify_PKCS1_PSS_mgf1