Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: content/child/webcrypto/openssl/util_openssl.cc

Issue 745443002: Check that usage isn't empty when generateKey() is called (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add more tests Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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/20 23:40:10 This test is not possible, as it will prevent impo
nharper 2014/11/21 22:12:01 Is it an issue that this affects behavior of key i
eroman 2014/11/21 22:55:47 Correct, importKey() must also throw a SyntaxError
184 return Status::ErrorCreateKeyBadUsages();
185 }
183 return Status::Success(); 186 return Status::Success();
184 } 187 }
185 188
186 Status ImportUnverifiedPkeyFromSpki(const CryptoData& key_data, 189 Status ImportUnverifiedPkeyFromSpki(const CryptoData& key_data,
187 int expected_pkey_id, 190 int expected_pkey_id,
188 crypto::ScopedEVP_PKEY* pkey) { 191 crypto::ScopedEVP_PKEY* pkey) {
189 if (!key_data.byte_length()) 192 if (!key_data.byte_length())
190 return Status::ErrorImportEmptyKeyData(); 193 return Status::ErrorImportEmptyKeyData();
191 194
192 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); 195 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 235
233 std::vector<uint8_t> BIGNUMToVector(const BIGNUM* n) { 236 std::vector<uint8_t> BIGNUMToVector(const BIGNUM* n) {
234 std::vector<uint8_t> v(BN_num_bytes(n)); 237 std::vector<uint8_t> v(BN_num_bytes(n));
235 BN_bn2bin(n, vector_as_array(&v)); 238 BN_bn2bin(n, vector_as_array(&v));
236 return v; 239 return v;
237 } 240 }
238 241
239 } // namespace webcrypto 242 } // namespace webcrypto
240 243
241 } // namespace content 244 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698