@@ -147,7 +147,12 @@ DataPointer DataPointer::SecureAlloc(size_t len) {
147147#ifndef OPENSSL_IS_BORINGSSL
148148 auto ptr = OPENSSL_secure_zalloc (len);
149149 if (ptr == nullptr ) return {};
150- return DataPointer (ptr, len, true );
150+ // OPENSSL_secure_zalloc transparently falls back to a regular allocation
151+ // when the secure heap is not initialized or is exhausted. Reflect the
152+ // actual provenance of the pointer so that reset() routes to the correct
153+ // free function (OPENSSL_secure_clear_free vs. OPENSSL_clear_free) and
154+ // callers of isSecure() get a truthful answer.
155+ return DataPointer (ptr, len, CRYPTO_secure_allocated (ptr) == 1 );
151156#else
152157 // BoringSSL does not implement the OPENSSL_secure_zalloc API.
153158 auto ptr = OPENSSL_malloc (len);
@@ -3103,9 +3108,13 @@ const Cipher Cipher::AES_256_GCM = Cipher::FromNid(NID_aes_256_gcm);
31033108const Cipher Cipher::AES_128_KW = Cipher::FromNid (NID_id_aes128_wrap);
31043109const Cipher Cipher::AES_192_KW = Cipher::FromNid (NID_id_aes192_wrap);
31053110const Cipher Cipher::AES_256_KW = Cipher::FromNid (NID_id_aes256_wrap);
3111+
3112+ #ifndef OPENSSL_IS_BORINGSSL
31063113const Cipher Cipher::AES_128_OCB = Cipher::FromNid (NID_aes_128_ocb);
31073114const Cipher Cipher::AES_192_OCB = Cipher::FromNid (NID_aes_192_ocb);
31083115const Cipher Cipher::AES_256_OCB = Cipher::FromNid (NID_aes_256_ocb);
3116+ #endif
3117+
31093118const Cipher Cipher::CHACHA20_POLY1305 = Cipher::FromNid (NID_chacha20_poly1305);
31103119
31113120bool Cipher::isGcmMode () const {