diff options
Diffstat (limited to 'content/child/webcrypto')
-rw-r--r-- | content/child/webcrypto/openssl/aes_gcm_openssl.cc | 43 | ||||
-rw-r--r-- | content/child/webcrypto/openssl/rsa_key_openssl.cc | 2 |
2 files changed, 24 insertions, 21 deletions
diff --git a/content/child/webcrypto/openssl/aes_gcm_openssl.cc b/content/child/webcrypto/openssl/aes_gcm_openssl.cc index de47dd8..0bc927b 100644 --- a/content/child/webcrypto/openssl/aes_gcm_openssl.cc +++ b/content/child/webcrypto/openssl/aes_gcm_openssl.cc @@ -71,7 +71,8 @@ Status AesGcmEncryptDecrypt(EncryptOrDecrypt mode, crypto::ScopedOpenSSL<EVP_AEAD_CTX, EVP_AEAD_CTX_cleanup>::Type ctx_cleanup( &ctx); - ssize_t len; + size_t len; + int ok; if (mode == DECRYPT) { if (data.byte_length() < tag_length_bytes) @@ -79,32 +80,34 @@ Status AesGcmEncryptDecrypt(EncryptOrDecrypt mode, buffer->resize(data.byte_length() - tag_length_bytes); - len = EVP_AEAD_CTX_open(&ctx, - Uint8VectorStart(buffer), - buffer->size(), - iv.bytes(), - iv.byte_length(), - data.bytes(), - data.byte_length(), - additional_data.bytes(), - additional_data.byte_length()); + ok = EVP_AEAD_CTX_open(&ctx, + Uint8VectorStart(buffer), + &len, + buffer->size(), + iv.bytes(), + iv.byte_length(), + data.bytes(), + data.byte_length(), + additional_data.bytes(), + additional_data.byte_length()); } else { // No need to check for unsigned integer overflow here (seal fails if // the output buffer is too small). buffer->resize(data.byte_length() + tag_length_bytes); - len = EVP_AEAD_CTX_seal(&ctx, - Uint8VectorStart(buffer), - buffer->size(), - iv.bytes(), - iv.byte_length(), - data.bytes(), - data.byte_length(), - additional_data.bytes(), - additional_data.byte_length()); + ok = EVP_AEAD_CTX_seal(&ctx, + Uint8VectorStart(buffer), + &len, + buffer->size(), + iv.bytes(), + iv.byte_length(), + data.bytes(), + data.byte_length(), + additional_data.bytes(), + additional_data.byte_length()); } - if (len < 0) + if (!ok) return Status::OperationError(); buffer->resize(len); return Status::Success(); diff --git a/content/child/webcrypto/openssl/rsa_key_openssl.cc b/content/child/webcrypto/openssl/rsa_key_openssl.cc index 8ba329a..42098eb 100644 --- a/content/child/webcrypto/openssl/rsa_key_openssl.cc +++ b/content/child/webcrypto/openssl/rsa_key_openssl.cc @@ -79,7 +79,7 @@ Status CreateRsaHashedKeyAlgorithm( std::vector<uint8_t> e(BN_num_bytes(rsa.get()->e)); if (e.size() == 0) return Status::ErrorUnexpected(); - if (static_cast<int>(e.size()) != BN_bn2bin(rsa.get()->e, &e[0])) + if (e.size() != BN_bn2bin(rsa.get()->e, &e[0])) return Status::ErrorUnexpected(); *key_algorithm = blink::WebCryptoKeyAlgorithm::createRsaHashed( |