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

Side by Side Diff: content/renderer/webcrypto/webcrypto_util.cc

Issue 116963002: [refactor] delete CreateHmacAlgorithmByHashOutputLen(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/webcrypto/webcrypto_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/renderer/webcrypto/webcrypto_util.h" 5 #include "content/renderer/webcrypto/webcrypto_util.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" 9 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h"
10 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" 10 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 return algorithm.rsaSsaParams()->hash(); 81 return algorithm.rsaSsaParams()->hash();
82 if (algorithm.rsaOaepParams()) 82 if (algorithm.rsaOaepParams())
83 return algorithm.rsaOaepParams()->hash(); 83 return algorithm.rsaOaepParams()->hash();
84 return blink::WebCryptoAlgorithm::createNull(); 84 return blink::WebCryptoAlgorithm::createNull();
85 } 85 }
86 86
87 blink::WebCryptoAlgorithm CreateAlgorithm(blink::WebCryptoAlgorithmId id) { 87 blink::WebCryptoAlgorithm CreateAlgorithm(blink::WebCryptoAlgorithmId id) {
88 return blink::WebCryptoAlgorithm::adoptParamsAndCreate(id, NULL); 88 return blink::WebCryptoAlgorithm::adoptParamsAndCreate(id, NULL);
89 } 89 }
90 90
91 blink::WebCryptoAlgorithm CreateHmacAlgorithmByHashOutputLen(
92 unsigned short hash_output_length_bits) {
93 blink::WebCryptoAlgorithmId hash_id;
94 switch (hash_output_length_bits) {
95 case 160:
96 hash_id = blink::WebCryptoAlgorithmIdSha1;
97 break;
98 case 224:
99 hash_id = blink::WebCryptoAlgorithmIdSha224;
100 break;
101 case 256:
102 hash_id = blink::WebCryptoAlgorithmIdSha256;
103 break;
104 case 384:
105 hash_id = blink::WebCryptoAlgorithmIdSha384;
106 break;
107 case 512:
108 hash_id = blink::WebCryptoAlgorithmIdSha512;
109 break;
110 default:
111 NOTREACHED();
112 return blink::WebCryptoAlgorithm::createNull();
113 }
114 return blink::WebCryptoAlgorithm::adoptParamsAndCreate(
115 blink::WebCryptoAlgorithmIdHmac,
116 new blink::WebCryptoHmacParams(CreateAlgorithm(hash_id)));
117 }
118
119 blink::WebCryptoAlgorithm CreateHmacAlgorithmByHashId( 91 blink::WebCryptoAlgorithm CreateHmacAlgorithmByHashId(
120 blink::WebCryptoAlgorithmId hash_id) { 92 blink::WebCryptoAlgorithmId hash_id) {
121 DCHECK(IsHashAlgorithm(hash_id)); 93 DCHECK(IsHashAlgorithm(hash_id));
122 return blink::WebCryptoAlgorithm::adoptParamsAndCreate( 94 return blink::WebCryptoAlgorithm::adoptParamsAndCreate(
123 blink::WebCryptoAlgorithmIdHmac, 95 blink::WebCryptoAlgorithmIdHmac,
124 new blink::WebCryptoHmacParams(CreateAlgorithm(hash_id))); 96 new blink::WebCryptoHmacParams(CreateAlgorithm(hash_id)));
125 } 97 }
126 98
127 blink::WebCryptoAlgorithm CreateHmacKeyGenAlgorithm( 99 blink::WebCryptoAlgorithm CreateHmacKeyGenAlgorithm(
128 blink::WebCryptoAlgorithmId hash_id, 100 blink::WebCryptoAlgorithmId hash_id,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 168
197 blink::WebCryptoAlgorithm CreateAesGcmKeyGenAlgorithm( 169 blink::WebCryptoAlgorithm CreateAesGcmKeyGenAlgorithm(
198 unsigned short key_length_bits) { 170 unsigned short key_length_bits) {
199 return CreateAesKeyGenAlgorithm(blink::WebCryptoAlgorithmIdAesGcm, 171 return CreateAesKeyGenAlgorithm(blink::WebCryptoAlgorithmIdAesGcm,
200 key_length_bits); 172 key_length_bits);
201 } 173 }
202 174
203 } // namespace webcrypto 175 } // namespace webcrypto
204 176
205 } // namespace content 177 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/webcrypto/webcrypto_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698