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

Side by Side Diff: components/webcrypto/algorithms/rsa_sign.cc

Issue 1461703009: Switch //components from vector_as_array to vector::data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: eroman comment Created 5 years 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 "base/numerics/safe_math.h" 5 #include "base/numerics/safe_math.h"
6 #include "base/stl_util.h"
7 #include "components/webcrypto/algorithms/rsa_sign.h" 6 #include "components/webcrypto/algorithms/rsa_sign.h"
8 #include "components/webcrypto/algorithms/util.h" 7 #include "components/webcrypto/algorithms/util.h"
9 #include "components/webcrypto/blink_key_handle.h" 8 #include "components/webcrypto/blink_key_handle.h"
10 #include "components/webcrypto/crypto_data.h" 9 #include "components/webcrypto/crypto_data.h"
11 #include "components/webcrypto/status.h" 10 #include "components/webcrypto/status.h"
12 #include "crypto/openssl_util.h" 11 #include "crypto/openssl_util.h"
13 #include "crypto/scoped_openssl_types.h" 12 #include "crypto/scoped_openssl_types.h"
14 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" 13 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h"
15 14
16 namespace webcrypto { 15 namespace webcrypto {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 status = ApplyRsaPssOptions(key, digest, pss_salt_length_bytes, pctx); 94 status = ApplyRsaPssOptions(key, digest, pss_salt_length_bytes, pctx);
96 if (status.IsError()) 95 if (status.IsError())
97 return status; 96 return status;
98 97
99 if (!EVP_DigestSignUpdate(ctx.get(), data.bytes(), data.byte_length()) || 98 if (!EVP_DigestSignUpdate(ctx.get(), data.bytes(), data.byte_length()) ||
100 !EVP_DigestSignFinal(ctx.get(), NULL, &sig_len)) { 99 !EVP_DigestSignFinal(ctx.get(), NULL, &sig_len)) {
101 return Status::OperationError(); 100 return Status::OperationError();
102 } 101 }
103 102
104 buffer->resize(sig_len); 103 buffer->resize(sig_len);
105 if (!EVP_DigestSignFinal(ctx.get(), vector_as_array(buffer), &sig_len)) 104 if (!EVP_DigestSignFinal(ctx.get(), buffer->data(), &sig_len))
106 return Status::OperationError(); 105 return Status::OperationError();
107 106
108 buffer->resize(sig_len); 107 buffer->resize(sig_len);
109 return Status::Success(); 108 return Status::Success();
110 } 109 }
111 110
112 Status RsaVerify(const blink::WebCryptoKey& key, 111 Status RsaVerify(const blink::WebCryptoKey& key,
113 unsigned int pss_salt_length_bytes, 112 unsigned int pss_salt_length_bytes,
114 const CryptoData& signature, 113 const CryptoData& signature,
115 const CryptoData& data, 114 const CryptoData& data,
(...skipping 21 matching lines...) Expand all
137 136
138 if (!EVP_DigestVerifyUpdate(ctx.get(), data.bytes(), data.byte_length())) 137 if (!EVP_DigestVerifyUpdate(ctx.get(), data.bytes(), data.byte_length()))
139 return Status::OperationError(); 138 return Status::OperationError();
140 139
141 *signature_match = 1 == EVP_DigestVerifyFinal(ctx.get(), signature.bytes(), 140 *signature_match = 1 == EVP_DigestVerifyFinal(ctx.get(), signature.bytes(),
142 signature.byte_length()); 141 signature.byte_length());
143 return Status::Success(); 142 return Status::Success();
144 } 143 }
145 144
146 } // namespace webcrypto 145 } // namespace webcrypto
OLDNEW
« no previous file with comments | « components/webcrypto/algorithms/rsa_oaep_unittest.cc ('k') | components/webcrypto/algorithms/rsa_ssa_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698