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

Side by Side Diff: content/child/webcrypto/platform_crypto_nss.cc

Issue 194203002: [webcrypto] Remove support for SHA-224 (CL 2 or 3). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/child/webcrypto/platform_crypto_openssl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/platform_crypto.h" 5 #include "content/child/webcrypto/platform_crypto.h"
6 6
7 #include <cryptohi.h> 7 #include <cryptohi.h>
8 #include <pk11pub.h> 8 #include <pk11pub.h>
9 #include <sechash.h> 9 #include <sechash.h>
10 10
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 // NSS requires non-const data even though it is just for input. 174 // NSS requires non-const data even though it is just for input.
175 const_cast<unsigned char*>(buffer.bytes()), buffer.byte_length()}; 175 const_cast<unsigned char*>(buffer.bytes()), buffer.byte_length()};
176 return item; 176 return item;
177 } 177 }
178 178
179 HASH_HashType WebCryptoAlgorithmToNSSHashType( 179 HASH_HashType WebCryptoAlgorithmToNSSHashType(
180 blink::WebCryptoAlgorithmId algorithm) { 180 blink::WebCryptoAlgorithmId algorithm) {
181 switch (algorithm) { 181 switch (algorithm) {
182 case blink::WebCryptoAlgorithmIdSha1: 182 case blink::WebCryptoAlgorithmIdSha1:
183 return HASH_AlgSHA1; 183 return HASH_AlgSHA1;
184 case blink::WebCryptoAlgorithmIdSha224:
185 return HASH_AlgSHA224;
186 case blink::WebCryptoAlgorithmIdSha256: 184 case blink::WebCryptoAlgorithmIdSha256:
187 return HASH_AlgSHA256; 185 return HASH_AlgSHA256;
188 case blink::WebCryptoAlgorithmIdSha384: 186 case blink::WebCryptoAlgorithmIdSha384:
189 return HASH_AlgSHA384; 187 return HASH_AlgSHA384;
190 case blink::WebCryptoAlgorithmIdSha512: 188 case blink::WebCryptoAlgorithmIdSha512:
191 return HASH_AlgSHA512; 189 return HASH_AlgSHA512;
192 default: 190 default:
193 // Not a digest algorithm. 191 // Not a digest algorithm.
194 return HASH_AlgNULL; 192 return HASH_AlgNULL;
195 } 193 }
196 } 194 }
197 195
198 CK_MECHANISM_TYPE WebCryptoHashToHMACMechanism( 196 CK_MECHANISM_TYPE WebCryptoHashToHMACMechanism(
199 const blink::WebCryptoAlgorithm& algorithm) { 197 const blink::WebCryptoAlgorithm& algorithm) {
200 switch (algorithm.id()) { 198 switch (algorithm.id()) {
201 case blink::WebCryptoAlgorithmIdSha1: 199 case blink::WebCryptoAlgorithmIdSha1:
202 return CKM_SHA_1_HMAC; 200 return CKM_SHA_1_HMAC;
203 case blink::WebCryptoAlgorithmIdSha224:
204 return CKM_SHA224_HMAC;
205 case blink::WebCryptoAlgorithmIdSha256: 201 case blink::WebCryptoAlgorithmIdSha256:
206 return CKM_SHA256_HMAC; 202 return CKM_SHA256_HMAC;
207 case blink::WebCryptoAlgorithmIdSha384: 203 case blink::WebCryptoAlgorithmIdSha384:
208 return CKM_SHA384_HMAC; 204 return CKM_SHA384_HMAC;
209 case blink::WebCryptoAlgorithmIdSha512: 205 case blink::WebCryptoAlgorithmIdSha512:
210 return CKM_SHA512_HMAC; 206 return CKM_SHA512_HMAC;
211 default: 207 default:
212 // Not a supported algorithm. 208 // Not a supported algorithm.
213 return CKM_INVALID_MECHANISM; 209 return CKM_INVALID_MECHANISM;
214 } 210 }
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 const blink::WebCryptoAlgorithm& hash, 797 const blink::WebCryptoAlgorithm& hash,
802 const CryptoData& data, 798 const CryptoData& data,
803 blink::WebArrayBuffer* buffer) { 799 blink::WebArrayBuffer* buffer) {
804 // Pick the NSS signing algorithm by combining RSA-SSA (RSA PKCS1) and the 800 // Pick the NSS signing algorithm by combining RSA-SSA (RSA PKCS1) and the
805 // inner hash of the input Web Crypto algorithm. 801 // inner hash of the input Web Crypto algorithm.
806 SECOidTag sign_alg_tag; 802 SECOidTag sign_alg_tag;
807 switch (hash.id()) { 803 switch (hash.id()) {
808 case blink::WebCryptoAlgorithmIdSha1: 804 case blink::WebCryptoAlgorithmIdSha1:
809 sign_alg_tag = SEC_OID_PKCS1_SHA1_WITH_RSA_ENCRYPTION; 805 sign_alg_tag = SEC_OID_PKCS1_SHA1_WITH_RSA_ENCRYPTION;
810 break; 806 break;
811 case blink::WebCryptoAlgorithmIdSha224:
812 sign_alg_tag = SEC_OID_PKCS1_SHA224_WITH_RSA_ENCRYPTION;
813 break;
814 case blink::WebCryptoAlgorithmIdSha256: 807 case blink::WebCryptoAlgorithmIdSha256:
815 sign_alg_tag = SEC_OID_PKCS1_SHA256_WITH_RSA_ENCRYPTION; 808 sign_alg_tag = SEC_OID_PKCS1_SHA256_WITH_RSA_ENCRYPTION;
816 break; 809 break;
817 case blink::WebCryptoAlgorithmIdSha384: 810 case blink::WebCryptoAlgorithmIdSha384:
818 sign_alg_tag = SEC_OID_PKCS1_SHA384_WITH_RSA_ENCRYPTION; 811 sign_alg_tag = SEC_OID_PKCS1_SHA384_WITH_RSA_ENCRYPTION;
819 break; 812 break;
820 case blink::WebCryptoAlgorithmIdSha512: 813 case blink::WebCryptoAlgorithmIdSha512:
821 sign_alg_tag = SEC_OID_PKCS1_SHA512_WITH_RSA_ENCRYPTION; 814 sign_alg_tag = SEC_OID_PKCS1_SHA512_WITH_RSA_ENCRYPTION;
822 break; 815 break;
823 default: 816 default:
(...skipping 18 matching lines...) Expand all
842 const CryptoData& signature, 835 const CryptoData& signature,
843 const CryptoData& data, 836 const CryptoData& data,
844 bool* signature_match) { 837 bool* signature_match) {
845 const SECItem signature_item = MakeSECItemForBuffer(signature); 838 const SECItem signature_item = MakeSECItemForBuffer(signature);
846 839
847 SECOidTag hash_alg_tag; 840 SECOidTag hash_alg_tag;
848 switch (hash.id()) { 841 switch (hash.id()) {
849 case blink::WebCryptoAlgorithmIdSha1: 842 case blink::WebCryptoAlgorithmIdSha1:
850 hash_alg_tag = SEC_OID_SHA1; 843 hash_alg_tag = SEC_OID_SHA1;
851 break; 844 break;
852 case blink::WebCryptoAlgorithmIdSha224:
853 hash_alg_tag = SEC_OID_SHA224;
854 break;
855 case blink::WebCryptoAlgorithmIdSha256: 845 case blink::WebCryptoAlgorithmIdSha256:
856 hash_alg_tag = SEC_OID_SHA256; 846 hash_alg_tag = SEC_OID_SHA256;
857 break; 847 break;
858 case blink::WebCryptoAlgorithmIdSha384: 848 case blink::WebCryptoAlgorithmIdSha384:
859 hash_alg_tag = SEC_OID_SHA384; 849 hash_alg_tag = SEC_OID_SHA384;
860 break; 850 break;
861 case blink::WebCryptoAlgorithmIdSha512: 851 case blink::WebCryptoAlgorithmIdSha512:
862 hash_alg_tag = SEC_OID_SHA512; 852 hash_alg_tag = SEC_OID_SHA512;
863 break; 853 break;
864 default: 854 default:
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 key_algorithm, 1191 key_algorithm,
1202 usage_mask); 1192 usage_mask);
1203 return Status::Success(); 1193 return Status::Success();
1204 } 1194 }
1205 1195
1206 } // namespace platform 1196 } // namespace platform
1207 1197
1208 } // namespace webcrypto 1198 } // namespace webcrypto
1209 1199
1210 } // namespace content 1200 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/child/webcrypto/platform_crypto_openssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698