@@ -396,15 +396,7 @@ std::optional<std::string> CryptoErrorList::pop_front() { |
396 | 396 |
|
397 | 397 | // ============================================================================ |
398 | 398 | DataPointer DataPointer::Alloc(size_t len) { |
399 | | -#ifdef OPENSSL_IS_BORINGSSL |
400 | | - // Boringssl does not implement OPENSSL_zalloc |
401 | | - auto ptr = OPENSSL_malloc(len); |
402 | | - if (ptr == nullptr) return {}; |
403 | | - memset(ptr, 0, len); |
404 | | - return DataPointer(ptr, len); |
405 | | -#else |
406 | 399 | return DataPointer(OPENSSL_zalloc(len), len); |
407 | | -#endif |
408 | 400 | } |
409 | 401 |
|
410 | 402 | DataPointer DataPointer::SecureAlloc(size_t len) { |
@@ -427,18 +419,11 @@ DataPointer DataPointer::SecureAlloc(size_t len) { |
427 | 419 | } |
428 | 420 |
|
429 | 421 | size_t DataPointer::GetSecureHeapUsed() { |
430 | | -#ifndef OPENSSL_IS_BORINGSSL |
431 | 422 | return CRYPTO_secure_malloc_initialized() ? CRYPTO_secure_used() : 0; |
432 | | -#else |
433 | | - // BoringSSL does not have the secure heap and therefore |
434 | | - // will always return 0. |
435 | | - return 0; |
436 | | -#endif |
437 | 423 | } |
438 | 424 |
|
439 | 425 | DataPointer::InitSecureHeapResult DataPointer::TryInitSecureHeap(size_t amount, |
440 | 426 | size_t min) { |
441 | | -#ifndef OPENSSL_IS_BORINGSSL |
442 | 427 | switch (CRYPTO_secure_malloc_init(amount, min)) { |
443 | 428 | case 0: |
444 | 429 | return InitSecureHeapResult::FAILED; |
@@ -449,10 +434,6 @@ DataPointer::InitSecureHeapResult DataPointer::TryInitSecureHeap(size_t amount, |
449 | 434 | default: |
450 | 435 | return InitSecureHeapResult::FAILED; |
451 | 436 | } |
452 | | -#else |
453 | | - // BoringSSL does not actually support the secure heap |
454 | | - return InitSecureHeapResult::FAILED; |
455 | | -#endif |
456 | 437 | } |
457 | 438 |
|
458 | 439 | DataPointer DataPointer::Copy(const Buffer<const void>& buffer) { |
@@ -580,12 +561,7 @@ BignumPointer BignumPointer::New() { |
580 | 561 | } |
581 | 562 |
|
582 | 563 | BignumPointer BignumPointer::NewSecure() { |
583 | | -#ifdef OPENSSL_IS_BORINGSSL |
584 | | - // Boringssl does not implement BN_secure_new. |
585 | | - return New(); |
586 | | -#else |
587 | 564 | return BignumPointer(BN_secure_new()); |
588 | | -#endif |
589 | 565 | } |
590 | 566 |
|
591 | 567 | BignumPointer& BignumPointer::operator=(BignumPointer&& other) noexcept { |
@@ -4288,59 +4264,6 @@ std::optional<uint32_t> SSLPointer::verifyPeerCertificate() const { |
4288 | 4264 | return std::nullopt; |
4289 | 4265 | } |
4290 | 4266 |
|
4291 | | -const char* SSLPointer::getClientHelloAlpn() const { |
4292 | | - if (ssl_ == nullptr) return {}; |
4293 | | -#ifndef OPENSSL_IS_BORINGSSL |
4294 | | - const unsigned char* buf; |
4295 | | - size_t len; |
4296 | | - size_t rem; |
4297 | | - |
4298 | | - if (!SSL_client_hello_get0_ext( |
4299 | | - get(), |
4300 | | - TLSEXT_TYPE_application_layer_protocol_negotiation, |
4301 | | - &buf, |
4302 | | - &rem) || |
4303 | | - rem < 2) { |
4304 | | - return {}; |
4305 | | - } |
4306 | | - |
4307 | | - len = (buf[0] << 8) | buf[1]; |
4308 | | - if (len + 2 != rem) return {}; |
4309 | | - return reinterpret_cast<const char*>(buf + 3); |
4310 | | -#else |
4311 | | - // Boringssl doesn't have a public API for this. |
4312 | | - return {}; |
4313 | | -#endif |
4314 | | -} |
4315 | | - |
4316 | | -const char* SSLPointer::getClientHelloServerName() const { |
4317 | | - if (ssl_ == nullptr) return {}; |
4318 | | -#ifndef OPENSSL_IS_BORINGSSL |
4319 | | - const unsigned char* buf; |
4320 | | - size_t len; |
4321 | | - size_t rem; |
4322 | | - |
4323 | | - if (!SSL_client_hello_get0_ext(get(), TLSEXT_TYPE_server_name, &buf, &rem) || |
4324 | | - rem <= 2) { |
4325 | | - return {}; |
4326 | | - } |
4327 | | - |
4328 | | - len = (*buf << 8) | *(buf + 1); |
4329 | | - if (len + 2 != rem) return {}; |
4330 | | - rem = len; |
4331 | | - |
4332 | | - if (rem == 0 || *(buf + 2) != TLSEXT_NAMETYPE_host_name) return {}; |
4333 | | - rem--; |
4334 | | - if (rem <= 2) return {}; |
4335 | | - len = (*(buf + 3) << 8) | *(buf + 4); |
4336 | | - if (len + 2 > rem) return {}; |
4337 | | - return reinterpret_cast<const char*>(buf + 5); |
4338 | | -#else |
4339 | | - // Boringssl doesn't have a public API for this. |
4340 | | - return {}; |
4341 | | -#endif |
4342 | | -} |
4343 | | - |
4344 | 4267 | std::optional<const std::string_view> SSLPointer::GetServerName( |
4345 | 4268 | const SSL* ssl) { |
4346 | 4269 | if (ssl == nullptr) return std::nullopt; |
|