OLD | NEW |
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/renderer/webcrypto/platform_crypto.h" | 5 #include "content/renderer/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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 Status AesGcmEncryptDecrypt(EncryptOrDecrypt mode, | 286 Status AesGcmEncryptDecrypt(EncryptOrDecrypt mode, |
287 SymKey* key, | 287 SymKey* key, |
288 const CryptoData& data, | 288 const CryptoData& data, |
289 const CryptoData& iv, | 289 const CryptoData& iv, |
290 const CryptoData& additional_data, | 290 const CryptoData& additional_data, |
291 unsigned int tag_length_bits, | 291 unsigned int tag_length_bits, |
292 blink::WebArrayBuffer* buffer) { | 292 blink::WebArrayBuffer* buffer) { |
293 if (!g_aes_gcm_support.Get().IsSupported()) | 293 if (!g_aes_gcm_support.Get().IsSupported()) |
294 return Status::ErrorUnsupported(); | 294 return Status::ErrorUnsupported(); |
295 | 295 |
296 // TODO(eroman): Is this necessary? | |
297 if ((tag_length_bits % 8) != 0) | |
298 return Status::ErrorInvalidAesGcmTagLength(); | |
299 unsigned int tag_length_bytes = tag_length_bits / 8; | 296 unsigned int tag_length_bytes = tag_length_bits / 8; |
300 | 297 |
301 CK_GCM_PARAMS gcm_params = {0}; | 298 CK_GCM_PARAMS gcm_params = {0}; |
302 gcm_params.pIv = const_cast<unsigned char*>(iv.bytes()); | 299 gcm_params.pIv = const_cast<unsigned char*>(iv.bytes()); |
303 gcm_params.ulIvLen = iv.byte_length(); | 300 gcm_params.ulIvLen = iv.byte_length(); |
304 | 301 |
305 gcm_params.pAAD = const_cast<unsigned char*>(additional_data.bytes()); | 302 gcm_params.pAAD = const_cast<unsigned char*>(additional_data.bytes()); |
306 gcm_params.ulAADLen = additional_data.byte_length(); | 303 gcm_params.ulAADLen = additional_data.byte_length(); |
307 | 304 |
308 gcm_params.ulTagBits = tag_length_bits; | 305 gcm_params.ulTagBits = tag_length_bits; |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 algorithm, | 1035 algorithm, |
1039 usage_mask); | 1036 usage_mask); |
1040 return Status::Success(); | 1037 return Status::Success(); |
1041 } | 1038 } |
1042 | 1039 |
1043 } // namespace platform | 1040 } // namespace platform |
1044 | 1041 |
1045 } // namespace webcrypto | 1042 } // namespace webcrypto |
1046 | 1043 |
1047 } // namespace content | 1044 } // namespace content |
OLD | NEW |