OLD | NEW |
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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 return CreateAesKeyGenAlgorithm(blink::WebCryptoAlgorithmIdAesCbc, | 165 return CreateAesKeyGenAlgorithm(blink::WebCryptoAlgorithmIdAesCbc, |
166 key_length_bits); | 166 key_length_bits); |
167 } | 167 } |
168 | 168 |
169 blink::WebCryptoAlgorithm CreateAesGcmKeyGenAlgorithm( | 169 blink::WebCryptoAlgorithm CreateAesGcmKeyGenAlgorithm( |
170 unsigned short key_length_bits) { | 170 unsigned short key_length_bits) { |
171 return CreateAesKeyGenAlgorithm(blink::WebCryptoAlgorithmIdAesGcm, | 171 return CreateAesKeyGenAlgorithm(blink::WebCryptoAlgorithmIdAesGcm, |
172 key_length_bits); | 172 key_length_bits); |
173 } | 173 } |
174 | 174 |
| 175 unsigned int ShaBlockSizeBytes(blink::WebCryptoAlgorithmId hash_id) { |
| 176 switch (hash_id) { |
| 177 case blink::WebCryptoAlgorithmIdSha1: |
| 178 case blink::WebCryptoAlgorithmIdSha224: |
| 179 case blink::WebCryptoAlgorithmIdSha256: |
| 180 return 64; |
| 181 case blink::WebCryptoAlgorithmIdSha384: |
| 182 case blink::WebCryptoAlgorithmIdSha512: |
| 183 return 128; |
| 184 default: |
| 185 NOTREACHED(); |
| 186 return 0; |
| 187 } |
| 188 } |
| 189 |
175 } // namespace webcrypto | 190 } // namespace webcrypto |
176 | 191 |
177 } // namespace content | 192 } // namespace content |
OLD | NEW |