Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 0.4.2-wip

- Update BoringSSL to e98a6564.
- Update BoringSSL to dd73e69a.

## 0.4.1

Expand Down
3 changes: 0 additions & 3 deletions lib/src/bindings/boringssl.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32447,9 +32447,6 @@ final class DIST_POINT_NAME_st extends ffi.Struct {
external int type;

external UnnamedUnion$4 name;

/// If relativename then this contains the full distribution point name
external ffi.Pointer<X509_NAME> dpname;
}

/// A DIST_POINT_st, aka `DIST_POINT`, represents a DistributionPoint structure
Expand Down
2 changes: 1 addition & 1 deletion third_party/boringssl/gen/bcm/aesni-gcm-x86_64-win.asm
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ $L$one_lsb:
DB 89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112
DB 114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0
ALIGN 64
section .text
section .text code align=64

section .pdata rdata align=4
ALIGN 4
Expand Down
6 changes: 3 additions & 3 deletions third_party/boringssl/gen/bcm/aesni-x86_64-win.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2499,7 +2499,7 @@ $L$key_rcon1b:
DB 32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115
DB 115,108,46,111,114,103,62,0
ALIGN 64
section .text
section .text code align=64

EXTERN __imp_RtlVirtualUnwind

Expand Down Expand Up @@ -2695,7 +2695,7 @@ $L$SEH_info_ctr32:
$L$SEH_info_cbc:
DB 9,0,0,0
DD cbc_se_handler wrt ..imagebase
section .pdata
section .pdata rdata align=4
ALIGN 4
DD $L$SEH_begin_aes_hw_set_encrypt_key_base_1 wrt ..imagebase
DD $L$SEH_end_aes_hw_set_encrypt_key_base_4 wrt ..imagebase
Expand All @@ -2706,7 +2706,7 @@ ALIGN 4
DD $L$SEH_info_aes_hw_set_encrypt_key_alt_0 wrt ..imagebase


section .xdata
section .xdata rdata align=8
ALIGN 4
$L$SEH_info_aes_hw_set_encrypt_key_base_0:
DB 1 ; version 1, no flags
Expand Down
2 changes: 1 addition & 1 deletion third_party/boringssl/gen/bcm/ghash-ssse3-x86_64-win.asm
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ $L$reverse_bytes:
; .Llow4_mask is an XMM mask which selects the low four bits of each byte.
$L$low4_mask:
DQ 0x0f0f0f0f0f0f0f0f,0x0f0f0f0f0f0f0f0f
section .text
section .text code align=64

section .pdata rdata align=4
ALIGN 4
Expand Down
2 changes: 1 addition & 1 deletion third_party/boringssl/gen/bcm/ghash-x86_64-win.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ ALIGN 64
DB 60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111
DB 114,103,62,0
ALIGN 64
section .text
section .text code align=64

section .pdata rdata align=4
ALIGN 4
Expand Down
2 changes: 1 addition & 1 deletion third_party/boringssl/gen/bcm/p256-x86_64-asm-win.asm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ $L$ord:
DQ 0xf3b9cac2fc632551,0xbce6faada7179e84,0xffffffffffffffff,0xffffffff00000000
$L$ordK:
DQ 0xccd1c8aaee00bc4f
section .text
section .text code align=64


; ###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion third_party/boringssl/gen/bcm/rsaz-avx2-win.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1846,7 +1846,7 @@ $L$inc:
DD 2,2,2,2,3,3,3,3
DD 4,4,4,4,4,4,4,4
ALIGN 64
section .text
section .text code align=64

EXTERN __imp_RtlVirtualUnwind

Expand Down
2 changes: 1 addition & 1 deletion third_party/boringssl/gen/bcm/sha1-x86_64-win.asm
Original file line number Diff line number Diff line change
Expand Up @@ -5560,7 +5560,7 @@ K_XX_XX:
DB 97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114
DB 103,62,0
ALIGN 64
section .text
section .text code align=64

EXTERN __imp_RtlVirtualUnwind

Expand Down
2 changes: 1 addition & 1 deletion third_party/boringssl/gen/bcm/sha256-x86_64-win.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1785,7 +1785,7 @@ K256:
DB 52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121
DB 32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46
DB 111,114,103,62,0
section .text
section .text code align=64

global sha256_block_data_order_hw

Expand Down
2 changes: 1 addition & 1 deletion third_party/boringssl/gen/bcm/sha512-x86_64-win.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1829,7 +1829,7 @@ K512:
DB 52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121
DB 32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46
DB 111,114,103,62,0
section .text
section .text code align=64

global sha512_block_data_order_avx

Expand Down
2 changes: 1 addition & 1 deletion third_party/boringssl/gen/bcm/vpaes-x86_64-win.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,7 @@ $L$ctr_add_two:
DB 85,110,105,118,101,114,115,105,116,121,41,0
ALIGN 64

section .text
section .text code align=64

EXTERN __imp_RtlVirtualUnwind

Expand Down
2 changes: 1 addition & 1 deletion third_party/boringssl/gen/bcm/x86_64-mont5-win.asm
Original file line number Diff line number Diff line change
Expand Up @@ -3698,7 +3698,7 @@ $L$inc:
DB 114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79
DB 71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111
DB 112,101,110,115,115,108,46,111,114,103,62,0
section .text
section .text code align=64

EXTERN __imp_RtlVirtualUnwind

Expand Down
2 changes: 1 addition & 1 deletion third_party/boringssl/gen/crypto/chacha-x86_64-win.asm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ $L$sixteen:
DB 95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32
DB 98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115
DB 108,46,111,114,103,62,0
section .text
section .text code align=64

global ChaCha20_ctr32_nohw

Expand Down
42 changes: 33 additions & 9 deletions third_party/boringssl/src/crypto/fipsmodule/entropy/jitter.cc.inc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include <openssl/mem.h>

#include "../../internal.h"
#include "internal.h"
#include "sha512.cc.inc"

Expand Down Expand Up @@ -88,6 +89,11 @@ class MemoryAccessSampler {
array_size_ & (array_size_ - 1)) {
abort();
}

if (boringssl_fips_break_test("JITTER_APT")) {
// In this break test, array_[0] is used to keep state. See below.
array_[0] = 0;
}
}

~MemoryAccessSampler() { OPENSSL_free(const_cast<uint8_t *>(array_)); }
Expand All @@ -104,16 +110,28 @@ class MemoryAccessSampler {
}

bool Next(uint64_t *out) {
// Perform some memory accesses and measure how long it took. The LCG is
// intended to defeat any CPU predictors and thus expose this code to as
// much system entropy as possible.
for (unsigned i = 0; i < num_samples_; i++) {
// The lower bits of an LCG tend to fall into short cycles and so are
// discarded here.
array_[(lcg_.Next() >> 6) & (array_size_ - 1)] += 1;
}
if (boringssl_fips_break_test("JITTER_RCT")) {
// To break the repetition test a constant value is returned.
*out = 1;
} else if (boringssl_fips_break_test("JITTER_APT")) {
// To break the adaptive test, but not the repetition test, a counter
// that advances every fourth call is returned. Since samples are
// processed by `DeltaSampler`, the tests see 0,0,0,1,... which exceeds
// the APT cutoff (348/512) without tripping the RCT (26).
*out = array_[0] >> 2;
array_[0]++;
} else {
// Perform some memory accesses and measure how long it took. The LCG is
// intended to defeat any CPU predictors and thus expose this code to as
// much system entropy as possible.
for (unsigned i = 0; i < num_samples_; i++) {
// The lower bits of an LCG tend to fall into short cycles and so are
// discarded here.
array_[(lcg_.Next() >> 6) & (array_size_ - 1)] += 1;
}

*out = GetTimestamp();
*out = GetTimestamp();
}
return true;
}

Expand Down Expand Up @@ -226,6 +244,9 @@ class RepetitionCountTest {
last_sample_ = sample;
}
if (count_ >= kThreshold) {
#if defined(BORINGSSL_FIPS_BREAK_TESTS)
fprintf(stderr, "Jitter RCT failure.\n");
#endif
return false;
}
*out = sample;
Expand Down Expand Up @@ -351,6 +372,9 @@ class AdaptiveProportionTest {
const uint16_t new_count = ++counts_[sample];

if (new_count > kThreshold) {
#if defined(BORINGSSL_FIPS_BREAK_TESTS)
fprintf(stderr, "Jitter APT failure.\n");
#endif
return false;
}

Expand Down
64 changes: 45 additions & 19 deletions third_party/boringssl/src/crypto/hpke/hpke.cc
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,18 @@ size_t EVP_HPKE_KEM_enc_len(const EVP_HPKE_KEM *kem) {
return kem->enc_len;
}

// TODO(crbug.com/535883377): Implement in terms of EVP_KEM for all supported
// HPKE KEMs.
size_t EVP_HPKE_KEM_shared_secret_len(const EVP_HPKE_KEM *kem) {
if (uses_evp(kem)) {
return EVP_KEM_secret_len(kem->evp_kem_func());
}
// All other KEMs have the same shared secret length. We assume we'll finish
// https://crbug.com/503758094 and move all KEMs to EVP before adding one that
// breaks this.
return SHA256_DIGEST_LENGTH;
}

// TODO(crbug.com/535883377): Implement in terms of EVP_KEM for all supported
// HPKE KEMs.
void EVP_HPKE_KEY_zero(EVP_HPKE_KEY *key) {
Expand Down Expand Up @@ -1274,44 +1286,58 @@ int EVP_HPKE_CTX_setup_sender_with_seed_for_testing(
return 1;
}

int EVP_HPKE_CTX_setup_recipient_with_shared_secret(
EVP_HPKE_CTX *ctx, const EVP_HPKE_KEM *kem, const EVP_HPKE_KDF *kdf,
const EVP_HPKE_AEAD *aead, const uint8_t *shared_secret,
size_t shared_secret_len, const uint8_t *info, size_t info_len) {
EVP_HPKE_CTX_zero(ctx);

if (shared_secret_len != EVP_HPKE_KEM_shared_secret_len(kem)) {
OPENSSL_PUT_ERROR(EVP, EVP_R_INVALID_BUFFER_SIZE);
return 0;
}

ctx->is_sender = 0;
ctx->kem = kem;
ctx->kdf = kdf;
ctx->aead = aead;
if (!hpke_key_schedule(ctx, HPKE_MODE_BASE, shared_secret, shared_secret_len,
info, info_len)) {
EVP_HPKE_CTX_cleanup(ctx);
return 0;
}
return 1;
}

int EVP_HPKE_CTX_setup_recipient(EVP_HPKE_CTX *ctx, const EVP_HPKE_KEY *key,
const EVP_HPKE_KDF *kdf,
const EVP_HPKE_AEAD *aead, const uint8_t *enc,
size_t enc_len, const uint8_t *info,
size_t info_len) {
EVP_HPKE_CTX_zero(ctx);
ctx->is_sender = 0;
ctx->kem = key->kem;
ctx->kdf = kdf;
ctx->aead = aead;

uint8_t shared_secret[MAX_SHARED_SECRET_LEN];
size_t shared_secret_len;

// TODO(crbug.com/535883377): Implement in terms of EVP_KEM for all supported
// HPKE KEMs.
int decap_ok;
if (uses_evp(key->kem)) {
const EVP_KEM *evp_kem = key->kem->evp_kem_func();
const EVP_PKEY *decap_key = key->pkey;
shared_secret_len = EVP_KEM_secret_len(evp_kem);
assert(size_t{MAX_SHARED_SECRET_LEN} >= shared_secret_len);

if (!EVP_KEM_decap(evp_kem, shared_secret, shared_secret_len, enc, enc_len,
decap_key) ||
!hpke_key_schedule(ctx, HPKE_MODE_BASE, shared_secret,
shared_secret_len, info, info_len)) {
EVP_HPKE_CTX_cleanup(ctx);
return 0;
}
return 1;
decap_ok = EVP_KEM_decap(evp_kem, shared_secret, shared_secret_len, enc,
enc_len, decap_key);
} else {
decap_ok = key->kem->decap(key, shared_secret, &shared_secret_len, enc,
enc_len);
}

if (!key->kem->decap(key, shared_secret, &shared_secret_len, enc, enc_len) ||
!hpke_key_schedule(ctx, HPKE_MODE_BASE, shared_secret, shared_secret_len,
info, info_len)) {
EVP_HPKE_CTX_cleanup(ctx);
return 0;
}
return 1;
return decap_ok && EVP_HPKE_CTX_setup_recipient_with_shared_secret(
ctx, key->kem, kdf, aead, shared_secret,
shared_secret_len, info, info_len);
}


Expand Down
26 changes: 1 addition & 25 deletions third_party/boringssl/src/crypto/x509/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,22 +263,6 @@ DECLARE_ASN1_FUNCTIONS_const(X509_CRL_INFO)

BSSL_NAMESPACE_END

// Values in idp_flags field
// IDP present
#define IDP_PRESENT 0x1
// IDP values inconsistent
#define IDP_INVALID 0x2
// onlyuser true
#define IDP_ONLYUSER 0x4
// onlyCA true
#define IDP_ONLYCA 0x8
// onlyattr true
#define IDP_ONLYATTR 0x10
// indirectCRL true
#define IDP_INDIRECT 0x20
// onlysomereasons present
#define IDP_REASONS 0x40

struct X509_crl_st {
// actual signature
bssl::X509_CRL_INFO *crl;
Expand All @@ -289,8 +273,6 @@ struct X509_crl_st {
// Copies of various extensions
AUTHORITY_KEYID *akid;
ISSUING_DIST_POINT *idp;
// Convenient breakdown of IDP
int idp_flags;
unsigned char crl_hash[SHA256_DIGEST_LENGTH];
} /* X509_CRL */;

Expand Down Expand Up @@ -625,10 +607,7 @@ STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line);
// GENERAL_NAME_cmp returns zero if `a` and `b` are equal and a non-zero
// value otherwise. Note this function does not provide a comparison suitable
// for sorting.
//
// This function is exported for testing.
OPENSSL_EXPORT int GENERAL_NAME_cmp(const GENERAL_NAME *a,
const GENERAL_NAME *b);
int GENERAL_NAME_cmp(const GENERAL_NAME *a, const GENERAL_NAME *b);

// X509_VERIFY_PARAM_lookup returns a pre-defined `X509_VERIFY_PARAM` named by
// `name`, or NULL if no such name is defined.
Expand All @@ -650,9 +629,6 @@ int X509_is_valid_trust_id(int trust);

int X509_PURPOSE_get_trust(const X509_PURPOSE *xp);

// TODO(https://crbug.com/boringssl/695): Remove this.
int DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, X509_NAME *iname);

// x509_parse_name parses a DER-encoded, X.509 Name from `cbs` and writes the
// result to `*out`. It returns one on success and zero on error.
int x509_parse_name(CBS *cbs, X509_NAME *out);
Expand Down
Loading