| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <openssl/evp.h> | 5 #include <openssl/evp.h> |
| 6 #include <stddef.h> | 6 #include <stddef.h> |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include "components/webcrypto/algorithms/rsa.h" | 10 #include "components/webcrypto/algorithms/rsa.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); | 44 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); |
| 45 | 45 |
| 46 EVP_PKEY* pkey = GetEVP_PKEY(key); | 46 EVP_PKEY* pkey = GetEVP_PKEY(key); |
| 47 const EVP_MD* digest = GetDigest(key.algorithm().rsaHashedParams()->hash()); | 47 const EVP_MD* digest = GetDigest(key.algorithm().rsaHashedParams()->hash()); |
| 48 if (!digest) | 48 if (!digest) |
| 49 return Status::ErrorUnsupported(); | 49 return Status::ErrorUnsupported(); |
| 50 | 50 |
| 51 crypto::ScopedEVP_PKEY_CTX ctx(EVP_PKEY_CTX_new(pkey, NULL)); | 51 crypto::ScopedEVP_PKEY_CTX ctx(EVP_PKEY_CTX_new(pkey, NULL)); |
| 52 | 52 |
| 53 if (!init_func(ctx.get()) || | 53 if (!init_func(ctx.get()) || |
| 54 1 != EVP_PKEY_CTX_set_rsa_padding(ctx.get(), RSA_PKCS1_OAEP_PADDING) || | 54 !EVP_PKEY_CTX_set_rsa_padding(ctx.get(), RSA_PKCS1_OAEP_PADDING) || |
| 55 1 != EVP_PKEY_CTX_set_rsa_oaep_md(ctx.get(), digest) || | 55 !EVP_PKEY_CTX_set_rsa_oaep_md(ctx.get(), digest) || |
| 56 1 != EVP_PKEY_CTX_set_rsa_mgf1_md(ctx.get(), digest)) { | 56 !EVP_PKEY_CTX_set_rsa_mgf1_md(ctx.get(), digest)) { |
| 57 return Status::OperationError(); | 57 return Status::OperationError(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 const blink::WebVector<uint8_t>& label = | 60 const blink::WebVector<uint8_t>& label = |
| 61 algorithm.rsaOaepParams()->optionalLabel(); | 61 algorithm.rsaOaepParams()->optionalLabel(); |
| 62 | 62 |
| 63 if (label.size()) { | 63 if (label.size()) { |
| 64 // Make a copy of the label, since the ctx takes ownership of it when | 64 // Make a copy of the label, since the ctx takes ownership of it when |
| 65 // calling set0_rsa_oaep_label(). | 65 // calling set0_rsa_oaep_label(). |
| 66 crypto::ScopedOpenSSLBytes label_copy; | 66 crypto::ScopedOpenSSLBytes label_copy; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 } | 138 } |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 } // namespace | 141 } // namespace |
| 142 | 142 |
| 143 scoped_ptr<AlgorithmImplementation> CreateRsaOaepImplementation() { | 143 scoped_ptr<AlgorithmImplementation> CreateRsaOaepImplementation() { |
| 144 return make_scoped_ptr(new RsaOaepImplementation); | 144 return make_scoped_ptr(new RsaOaepImplementation); |
| 145 } | 145 } |
| 146 | 146 |
| 147 } // namespace webcrypto | 147 } // namespace webcrypto |
| OLD | NEW |