Chromium Code Reviews| 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 "content/child/webcrypto/openssl/util_openssl.h" | 5 #include "content/child/webcrypto/openssl/util_openssl.h" |
| 6 | 6 |
| 7 #include <openssl/evp.h> | 7 #include <openssl/evp.h> |
| 8 #include <openssl/pkcs12.h> | 8 #include <openssl/pkcs12.h> |
| 9 | 9 |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 // Serialize the key at creation time so that if structured cloning is | 173 // Serialize the key at creation time so that if structured cloning is |
| 174 // requested it can be done synchronously from the Blink thread. | 174 // requested it can be done synchronously from the Blink thread. |
| 175 std::vector<uint8_t> pkcs8_data; | 175 std::vector<uint8_t> pkcs8_data; |
| 176 Status status = ExportPKeyPkcs8(private_key.get(), &pkcs8_data); | 176 Status status = ExportPKeyPkcs8(private_key.get(), &pkcs8_data); |
| 177 if (status.IsError()) | 177 if (status.IsError()) |
| 178 return status; | 178 return status; |
| 179 | 179 |
| 180 *key = blink::WebCryptoKey::create( | 180 *key = blink::WebCryptoKey::create( |
| 181 new AsymKeyOpenSsl(private_key.Pass(), CryptoData(pkcs8_data)), | 181 new AsymKeyOpenSsl(private_key.Pass(), CryptoData(pkcs8_data)), |
| 182 blink::WebCryptoKeyTypePrivate, extractable, algorithm, usages); | 182 blink::WebCryptoKeyTypePrivate, extractable, algorithm, usages); |
| 183 if (key->usages() == 0) | |
|
eroman
2014/11/21 23:35:34
Per our discussion this is best left to a follow-u
nharper
2014/11/22 00:26:45
I moved this check up to the GenerateKey() functio
| |
| 184 return Status::ErrorCreateKeyEmptyUsages(); | |
| 183 return Status::Success(); | 185 return Status::Success(); |
| 184 } | 186 } |
| 185 | 187 |
| 186 Status ImportUnverifiedPkeyFromSpki(const CryptoData& key_data, | 188 Status ImportUnverifiedPkeyFromSpki(const CryptoData& key_data, |
| 187 int expected_pkey_id, | 189 int expected_pkey_id, |
| 188 crypto::ScopedEVP_PKEY* pkey) { | 190 crypto::ScopedEVP_PKEY* pkey) { |
| 189 if (!key_data.byte_length()) | 191 if (!key_data.byte_length()) |
| 190 return Status::ErrorImportEmptyKeyData(); | 192 return Status::ErrorImportEmptyKeyData(); |
| 191 | 193 |
| 192 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); | 194 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 | 234 |
| 233 std::vector<uint8_t> BIGNUMToVector(const BIGNUM* n) { | 235 std::vector<uint8_t> BIGNUMToVector(const BIGNUM* n) { |
| 234 std::vector<uint8_t> v(BN_num_bytes(n)); | 236 std::vector<uint8_t> v(BN_num_bytes(n)); |
| 235 BN_bn2bin(n, vector_as_array(&v)); | 237 BN_bn2bin(n, vector_as_array(&v)); |
| 236 return v; | 238 return v; |
| 237 } | 239 } |
| 238 | 240 |
| 239 } // namespace webcrypto | 241 } // namespace webcrypto |
| 240 | 242 |
| 241 } // namespace content | 243 } // namespace content |
| OLD | NEW |