| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 {"HMAC", 4, blink::WebCryptoAlgorithmIdHmac}, | 66 {"HMAC", 4, blink::WebCryptoAlgorithmIdHmac}, |
| 67 {"SHA-1", 5, blink::WebCryptoAlgorithmIdSha1}, | 67 {"SHA-1", 5, blink::WebCryptoAlgorithmIdSha1}, |
| 68 {"AES-KW", 6, blink::WebCryptoAlgorithmIdAesKw}, | 68 {"AES-KW", 6, blink::WebCryptoAlgorithmIdAesKw}, |
| 69 {"SHA-512", 7, blink::WebCryptoAlgorithmIdSha512}, | 69 {"SHA-512", 7, blink::WebCryptoAlgorithmIdSha512}, |
| 70 {"SHA-384", 7, blink::WebCryptoAlgorithmIdSha384}, | 70 {"SHA-384", 7, blink::WebCryptoAlgorithmIdSha384}, |
| 71 {"SHA-256", 7, blink::WebCryptoAlgorithmIdSha256}, | 71 {"SHA-256", 7, blink::WebCryptoAlgorithmIdSha256}, |
| 72 {"AES-CBC", 7, blink::WebCryptoAlgorithmIdAesCbc}, | 72 {"AES-CBC", 7, blink::WebCryptoAlgorithmIdAesCbc}, |
| 73 {"AES-GCM", 7, blink::WebCryptoAlgorithmIdAesGcm}, | 73 {"AES-GCM", 7, blink::WebCryptoAlgorithmIdAesGcm}, |
| 74 {"AES-CTR", 7, blink::WebCryptoAlgorithmIdAesCtr}, | 74 {"AES-CTR", 7, blink::WebCryptoAlgorithmIdAesCtr}, |
| 75 {"RSA-OAEP", 8, blink::WebCryptoAlgorithmIdRsaOaep}, | 75 {"RSA-OAEP", 8, blink::WebCryptoAlgorithmIdRsaOaep}, |
| 76 {"RSAES-PKCS1-V1_5", 16, blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5}, |
| 76 {"RSASSA-PKCS1-V1_5", 17, blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5}, | 77 {"RSASSA-PKCS1-V1_5", 17, blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5}, |
| 77 }; | 78 }; |
| 78 | 79 |
| 79 typedef char ParamsTypeOrUndefined; | 80 typedef char ParamsTypeOrUndefined; |
| 80 const ParamsTypeOrUndefined Undefined = -1; | 81 const ParamsTypeOrUndefined Undefined = -1; |
| 81 | 82 |
| 82 struct AlgorithmInfo { | 83 struct AlgorithmInfo { |
| 83 // The canonical (case-sensitive) name for the algorithm. | 84 // The canonical (case-sensitive) name for the algorithm. |
| 84 const char* name; | 85 const char* name; |
| 85 | 86 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 blink::WebCryptoAlgorithmParamsTypeNone, // Verify | 127 blink::WebCryptoAlgorithmParamsTypeNone, // Verify |
| 127 Undefined, // Digest | 128 Undefined, // Digest |
| 128 blink::WebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams, // Generat
eKey | 129 blink::WebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams, // Generat
eKey |
| 129 blink::WebCryptoAlgorithmParamsTypeRsaHashedImportParams, // ImportK
ey | 130 blink::WebCryptoAlgorithmParamsTypeRsaHashedImportParams, // ImportK
ey |
| 130 Undefined, // DeriveKey | 131 Undefined, // DeriveKey |
| 131 Undefined, // DeriveBits | 132 Undefined, // DeriveBits |
| 132 Undefined, // WrapKey | 133 Undefined, // WrapKey |
| 133 Undefined // UnwrapKey | 134 Undefined // UnwrapKey |
| 134 } | 135 } |
| 135 }, { // Index 3 | 136 }, { // Index 3 |
| 137 "RSAES-PKCS1-v1_5", { |
| 138 blink::WebCryptoAlgorithmParamsTypeNone, // Encrypt |
| 139 blink::WebCryptoAlgorithmParamsTypeNone, // Decrypt |
| 140 Undefined, // Sign |
| 141 Undefined, // Verify |
| 142 Undefined, // Digest |
| 143 blink::WebCryptoAlgorithmParamsTypeRsaKeyGenParams, // GenerateKey |
| 144 blink::WebCryptoAlgorithmParamsTypeNone, // ImportKey |
| 145 Undefined, // DeriveKey |
| 146 Undefined, // DeriveBits |
| 147 blink::WebCryptoAlgorithmParamsTypeNone, // WrapKey |
| 148 blink::WebCryptoAlgorithmParamsTypeNone // UnwrapKey |
| 149 } |
| 150 }, { // Index 4 |
| 136 "SHA-1", { | 151 "SHA-1", { |
| 137 Undefined, // Encrypt | 152 Undefined, // Encrypt |
| 138 Undefined, // Decrypt | 153 Undefined, // Decrypt |
| 139 Undefined, // Sign | 154 Undefined, // Sign |
| 140 Undefined, // Verify | 155 Undefined, // Verify |
| 141 blink::WebCryptoAlgorithmParamsTypeNone, // Digest | 156 blink::WebCryptoAlgorithmParamsTypeNone, // Digest |
| 142 Undefined, // GenerateKey | 157 Undefined, // GenerateKey |
| 143 Undefined, // ImportKey | 158 Undefined, // ImportKey |
| 144 Undefined, // DeriveKey | 159 Undefined, // DeriveKey |
| 145 Undefined, // DeriveBits | 160 Undefined, // DeriveBits |
| 146 Undefined, // WrapKey | 161 Undefined, // WrapKey |
| 147 Undefined // UnwrapKey | 162 Undefined // UnwrapKey |
| 148 } | 163 } |
| 149 }, { // Index 4 | 164 }, { // Index 5 |
| 150 "SHA-256", { | 165 "SHA-256", { |
| 151 Undefined, // Encrypt | 166 Undefined, // Encrypt |
| 152 Undefined, // Decrypt | 167 Undefined, // Decrypt |
| 153 Undefined, // Sign | 168 Undefined, // Sign |
| 154 Undefined, // Verify | 169 Undefined, // Verify |
| 155 blink::WebCryptoAlgorithmParamsTypeNone, // Digest | 170 blink::WebCryptoAlgorithmParamsTypeNone, // Digest |
| 156 Undefined, // GenerateKey | 171 Undefined, // GenerateKey |
| 157 Undefined, // ImportKey | 172 Undefined, // ImportKey |
| 158 Undefined, // DeriveKey | 173 Undefined, // DeriveKey |
| 159 Undefined, // DeriveBits | 174 Undefined, // DeriveBits |
| 160 Undefined, // WrapKey | 175 Undefined, // WrapKey |
| 161 Undefined // UnwrapKey | 176 Undefined // UnwrapKey |
| 162 } | 177 } |
| 163 }, { // Index 5 | 178 }, { // Index 6 |
| 164 "SHA-384", { | 179 "SHA-384", { |
| 165 Undefined, // Encrypt | 180 Undefined, // Encrypt |
| 166 Undefined, // Decrypt | 181 Undefined, // Decrypt |
| 167 Undefined, // Sign | 182 Undefined, // Sign |
| 168 Undefined, // Verify | 183 Undefined, // Verify |
| 169 blink::WebCryptoAlgorithmParamsTypeNone, // Digest | 184 blink::WebCryptoAlgorithmParamsTypeNone, // Digest |
| 170 Undefined, // GenerateKey | 185 Undefined, // GenerateKey |
| 171 Undefined, // ImportKey | 186 Undefined, // ImportKey |
| 172 Undefined, // DeriveKey | 187 Undefined, // DeriveKey |
| 173 Undefined, // DeriveBits | 188 Undefined, // DeriveBits |
| 174 Undefined, // WrapKey | 189 Undefined, // WrapKey |
| 175 Undefined // UnwrapKey | 190 Undefined // UnwrapKey |
| 176 } | 191 } |
| 177 }, { // Index 6 | 192 }, { // Index 7 |
| 178 "SHA-512", { | 193 "SHA-512", { |
| 179 Undefined, // Encrypt | 194 Undefined, // Encrypt |
| 180 Undefined, // Decrypt | 195 Undefined, // Decrypt |
| 181 Undefined, // Sign | 196 Undefined, // Sign |
| 182 Undefined, // Verify | 197 Undefined, // Verify |
| 183 blink::WebCryptoAlgorithmParamsTypeNone, // Digest | 198 blink::WebCryptoAlgorithmParamsTypeNone, // Digest |
| 184 Undefined, // GenerateKey | 199 Undefined, // GenerateKey |
| 185 Undefined, // ImportKey | 200 Undefined, // ImportKey |
| 186 Undefined, // DeriveKey | 201 Undefined, // DeriveKey |
| 187 Undefined, // DeriveBits | 202 Undefined, // DeriveBits |
| 188 Undefined, // WrapKey | 203 Undefined, // WrapKey |
| 189 Undefined // UnwrapKey | 204 Undefined // UnwrapKey |
| 190 } | 205 } |
| 191 }, { // Index 7 | 206 }, { // Index 8 |
| 192 "AES-GCM", { | 207 "AES-GCM", { |
| 193 blink::WebCryptoAlgorithmParamsTypeAesGcmParams, // Encrypt | 208 blink::WebCryptoAlgorithmParamsTypeAesGcmParams, // Encrypt |
| 194 blink::WebCryptoAlgorithmParamsTypeAesGcmParams, // Decrypt | 209 blink::WebCryptoAlgorithmParamsTypeAesGcmParams, // Decrypt |
| 195 Undefined, // Sign | 210 Undefined, // Sign |
| 196 Undefined, // Verify | 211 Undefined, // Verify |
| 197 Undefined, // Digest | 212 Undefined, // Digest |
| 198 blink::WebCryptoAlgorithmParamsTypeAesKeyGenParams, // GenerateKey | 213 blink::WebCryptoAlgorithmParamsTypeAesKeyGenParams, // GenerateKey |
| 199 blink::WebCryptoAlgorithmParamsTypeNone, // ImportKey | 214 blink::WebCryptoAlgorithmParamsTypeNone, // ImportKey |
| 200 Undefined, // DeriveKey | 215 Undefined, // DeriveKey |
| 201 Undefined, // DeriveBits | 216 Undefined, // DeriveBits |
| 202 blink::WebCryptoAlgorithmParamsTypeAesGcmParams, // WrapKey | 217 blink::WebCryptoAlgorithmParamsTypeAesGcmParams, // WrapKey |
| 203 blink::WebCryptoAlgorithmParamsTypeAesGcmParams // UnwrapKey | 218 blink::WebCryptoAlgorithmParamsTypeAesGcmParams // UnwrapKey |
| 204 } | 219 } |
| 205 }, { // Index 8 | 220 }, { // Index 9 |
| 206 "RSA-OAEP", { | 221 "RSA-OAEP", { |
| 207 blink::WebCryptoAlgorithmParamsTypeRsaOaepParams, // Encrypt | 222 blink::WebCryptoAlgorithmParamsTypeRsaOaepParams, // Encrypt |
| 208 blink::WebCryptoAlgorithmParamsTypeRsaOaepParams, // Decrypt | 223 blink::WebCryptoAlgorithmParamsTypeRsaOaepParams, // Decrypt |
| 209 Undefined, // Sign | 224 Undefined, // Sign |
| 210 Undefined, // Verify | 225 Undefined, // Verify |
| 211 Undefined, // Digest | 226 Undefined, // Digest |
| 212 blink::WebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams, // Generat
eKey | 227 blink::WebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams, // Generat
eKey |
| 213 blink::WebCryptoAlgorithmParamsTypeRsaHashedImportParams, // ImportK
ey | 228 blink::WebCryptoAlgorithmParamsTypeRsaHashedImportParams, // ImportK
ey |
| 214 Undefined, // DeriveKey | 229 Undefined, // DeriveKey |
| 215 Undefined, // DeriveBits | 230 Undefined, // DeriveBits |
| 216 blink::WebCryptoAlgorithmParamsTypeRsaOaepParams, // WrapKey | 231 blink::WebCryptoAlgorithmParamsTypeRsaOaepParams, // WrapKey |
| 217 blink::WebCryptoAlgorithmParamsTypeRsaOaepParams // UnwrapKey | 232 blink::WebCryptoAlgorithmParamsTypeRsaOaepParams // UnwrapKey |
| 218 } | 233 } |
| 219 }, { // Index 9 | 234 }, { // Index 10 |
| 220 "AES-CTR", { | 235 "AES-CTR", { |
| 221 blink::WebCryptoAlgorithmParamsTypeAesCtrParams, // Encrypt | 236 blink::WebCryptoAlgorithmParamsTypeAesCtrParams, // Encrypt |
| 222 blink::WebCryptoAlgorithmParamsTypeAesCtrParams, // Decrypt | 237 blink::WebCryptoAlgorithmParamsTypeAesCtrParams, // Decrypt |
| 223 Undefined, // Sign | 238 Undefined, // Sign |
| 224 Undefined, // Verify | 239 Undefined, // Verify |
| 225 Undefined, // Digest | 240 Undefined, // Digest |
| 226 blink::WebCryptoAlgorithmParamsTypeAesKeyGenParams, // GenerateKey | 241 blink::WebCryptoAlgorithmParamsTypeAesKeyGenParams, // GenerateKey |
| 227 blink::WebCryptoAlgorithmParamsTypeNone, // ImportKey | 242 blink::WebCryptoAlgorithmParamsTypeNone, // ImportKey |
| 228 Undefined, // DeriveKey | 243 Undefined, // DeriveKey |
| 229 Undefined, // DeriveBits | 244 Undefined, // DeriveBits |
| 230 blink::WebCryptoAlgorithmParamsTypeAesCtrParams, // WrapKey | 245 blink::WebCryptoAlgorithmParamsTypeAesCtrParams, // WrapKey |
| 231 blink::WebCryptoAlgorithmParamsTypeAesCtrParams // UnwrapKey | 246 blink::WebCryptoAlgorithmParamsTypeAesCtrParams // UnwrapKey |
| 232 } | 247 } |
| 233 }, { // Index 10 | 248 }, { // Index 11 |
| 234 "AES-KW", { | 249 "AES-KW", { |
| 235 Undefined, // Encrypt | 250 Undefined, // Encrypt |
| 236 Undefined, // Decrypt | 251 Undefined, // Decrypt |
| 237 Undefined, // Sign | 252 Undefined, // Sign |
| 238 Undefined, // Verify | 253 Undefined, // Verify |
| 239 Undefined, // Digest | 254 Undefined, // Digest |
| 240 blink::WebCryptoAlgorithmParamsTypeAesKeyGenParams, // GenerateKey | 255 blink::WebCryptoAlgorithmParamsTypeAesKeyGenParams, // GenerateKey |
| 241 blink::WebCryptoAlgorithmParamsTypeNone, // ImportKey | 256 blink::WebCryptoAlgorithmParamsTypeNone, // ImportKey |
| 242 Undefined, // DeriveKey | 257 Undefined, // DeriveKey |
| 243 Undefined, // DeriveBits | 258 Undefined, // DeriveBits |
| 244 blink::WebCryptoAlgorithmParamsTypeNone, // WrapKey | 259 blink::WebCryptoAlgorithmParamsTypeNone, // WrapKey |
| 245 blink::WebCryptoAlgorithmParamsTypeNone // UnwrapKey | 260 blink::WebCryptoAlgorithmParamsTypeNone // UnwrapKey |
| 246 } | 261 } |
| 247 }, | 262 }, |
| 248 }; | 263 }; |
| 249 | 264 |
| 250 // Initializing the algorithmIdToInfo table above depends on knowing the enum | 265 // Initializing the algorithmIdToInfo table above depends on knowing the enum |
| 251 // values for algorithm IDs. If those ever change, the table will need to be | 266 // values for algorithm IDs. If those ever change, the table will need to be |
| 252 // updated. | 267 // updated. |
| 253 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdAesCbc == 0, AesCbc_idDoesntMatch); | 268 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdAesCbc == 0, AesCbc_idDoesntMatch); |
| 254 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdHmac == 1, Hmac_idDoesntMatch); | 269 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdHmac == 1, Hmac_idDoesntMatch); |
| 255 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 == 2, RsaSsaPkcs1v1_5_
idDoesntMatch); | 270 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 == 2, RsaSsaPkcs1v1_5_
idDoesntMatch); |
| 256 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdSha1 == 3, Sha1_idDoesntMatch); | 271 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5 == 3, RsaEsPkcs1v1_5_id
DoesntMatch); |
| 257 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdSha256 == 4, Sha256_idDoesntMatch); | 272 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdSha1 == 4, Sha1_idDoesntMatch); |
| 258 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdSha384 == 5, Sha384_idDoesntMatch); | 273 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdSha256 == 5, Sha256_idDoesntMatch); |
| 259 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdSha512 == 6, Sha512_idDoesntMatch); | 274 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdSha384 == 6, Sha384_idDoesntMatch); |
| 260 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdAesGcm == 7, AesGcm_idDoesntMatch); | 275 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdSha512 == 7, Sha512_idDoesntMatch); |
| 261 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdRsaOaep == 8, RsaOaep_idDoesntMatch); | 276 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdAesGcm == 8, AesGcm_idDoesntMatch); |
| 262 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdAesCtr == 9, AesCtr_idDoesntMatch); | 277 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdRsaOaep == 9, RsaOaep_idDoesntMatch); |
| 263 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdAesKw == 10, AesKw_idDoesntMatch); | 278 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdAesCtr == 10, AesCtr_idDoesntMatch); |
| 264 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdLast == 10, Last_idDoesntMatch); | 279 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdAesKw == 11, AesKw_idDoesntMatch); |
| 280 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdLast == 11, Last_idDoesntMatch); |
| 265 COMPILE_ASSERT(10 == LastAlgorithmOperation, UpdateParamsMapping); | 281 COMPILE_ASSERT(10 == LastAlgorithmOperation, UpdateParamsMapping); |
| 266 | 282 |
| 267 #if ASSERT_ENABLED | 283 #if ASSERT_ENABLED |
| 268 | 284 |
| 269 // Essentially std::is_sorted() (however that function is new to C++11). | 285 // Essentially std::is_sorted() (however that function is new to C++11). |
| 270 template <typename Iterator> | 286 template <typename Iterator> |
| 271 bool isSorted(Iterator begin, Iterator end) | 287 bool isSorted(Iterator begin, Iterator end) |
| 272 { | 288 { |
| 273 if (begin == end) | 289 if (begin == end) |
| 274 return true; | 290 return true; |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 blink::WebCryptoAlgorithm hash; | 712 blink::WebCryptoAlgorithm hash; |
| 697 if (!parseHash(raw, hash, context, result)) | 713 if (!parseHash(raw, hash, context, result)) |
| 698 return false; | 714 return false; |
| 699 | 715 |
| 700 params = adoptPtr(new blink::WebCryptoRsaHashedImportParams(hash)); | 716 params = adoptPtr(new blink::WebCryptoRsaHashedImportParams(hash)); |
| 701 return true; | 717 return true; |
| 702 } | 718 } |
| 703 | 719 |
| 704 // Defined by the WebCrypto spec as: | 720 // Defined by the WebCrypto spec as: |
| 705 // | 721 // |
| 722 // dictionary RsaKeyGenParams : Algorithm { |
| 723 // unsigned long modulusLength; |
| 724 // BigInteger publicExponent; |
| 725 // }; |
| 726 bool parseRsaKeyGenParams(const Dictionary& raw, uint32_t& modulusLength, RefPtr
<Uint8Array>& publicExponent, const ErrorContext& context, CryptoResult* result) |
| 727 { |
| 728 if (!getUint32(raw, "modulusLength", modulusLength, context, result)) |
| 729 return false; |
| 730 |
| 731 if (!getBigInteger(raw, "publicExponent", publicExponent, context, result)) |
| 732 return false; |
| 733 |
| 734 return true; |
| 735 } |
| 736 |
| 737 bool parseRsaKeyGenParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorith
mParams>& params, const ErrorContext& context, CryptoResult* result) |
| 738 { |
| 739 uint32_t modulusLength; |
| 740 RefPtr<Uint8Array> publicExponent; |
| 741 if (!parseRsaKeyGenParams(raw, modulusLength, publicExponent, context, resul
t)) |
| 742 return false; |
| 743 |
| 744 params = adoptPtr(new blink::WebCryptoRsaKeyGenParams(modulusLength, static_
cast<const unsigned char*>(publicExponent->baseAddress()), publicExponent->byteL
ength())); |
| 745 return true; |
| 746 } |
| 747 |
| 748 // Defined by the WebCrypto spec as: |
| 749 // |
| 706 // dictionary RsaHashedKeyGenParams : RsaKeyGenParams { | 750 // dictionary RsaHashedKeyGenParams : RsaKeyGenParams { |
| 707 // AlgorithmIdentifier hash; | 751 // AlgorithmIdentifier hash; |
| 708 // }; | 752 // }; |
| 709 // | |
| 710 // dictionary RsaKeyGenParams : Algorithm { | |
| 711 // unsigned long modulusLength; | |
| 712 // BigInteger publicExponent; | |
| 713 // }; | |
| 714 bool parseRsaHashedKeyGenParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAl
gorithmParams>& params, const ErrorContext& context, CryptoResult* result) | 753 bool parseRsaHashedKeyGenParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAl
gorithmParams>& params, const ErrorContext& context, CryptoResult* result) |
| 715 { | 754 { |
| 716 uint32_t modulusLength; | 755 uint32_t modulusLength; |
| 717 if (!getUint32(raw, "modulusLength", modulusLength, context, result)) | |
| 718 return false; | |
| 719 | |
| 720 RefPtr<Uint8Array> publicExponent; | 756 RefPtr<Uint8Array> publicExponent; |
| 721 if (!getBigInteger(raw, "publicExponent", publicExponent, context, result)) | 757 if (!parseRsaKeyGenParams(raw, modulusLength, publicExponent, context, resul
t)) |
| 722 return false; | 758 return false; |
| 723 | 759 |
| 724 blink::WebCryptoAlgorithm hash; | 760 blink::WebCryptoAlgorithm hash; |
| 725 if (!parseHash(raw, hash, context, result)) | 761 if (!parseHash(raw, hash, context, result)) |
| 726 return false; | 762 return false; |
| 727 | 763 |
| 728 params = adoptPtr(new blink::WebCryptoRsaHashedKeyGenParams(hash, modulusLen
gth, static_cast<const unsigned char*>(publicExponent->baseAddress()), publicExp
onent->byteLength())); | 764 params = adoptPtr(new blink::WebCryptoRsaHashedKeyGenParams(hash, modulusLen
gth, static_cast<const unsigned char*>(publicExponent->baseAddress()), publicExp
onent->byteLength())); |
| 729 return true; | 765 return true; |
| 730 } | 766 } |
| 731 | 767 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 return parseHmacImportParams(raw, params, context, result); | 853 return parseHmacImportParams(raw, params, context, result); |
| 818 case blink::WebCryptoAlgorithmParamsTypeHmacKeyGenParams: | 854 case blink::WebCryptoAlgorithmParamsTypeHmacKeyGenParams: |
| 819 context.add("HmacKeyGenParams"); | 855 context.add("HmacKeyGenParams"); |
| 820 return parseHmacKeyGenParams(raw, params, context, result); | 856 return parseHmacKeyGenParams(raw, params, context, result); |
| 821 case blink::WebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams: | 857 case blink::WebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams: |
| 822 context.add("RsaHashedKeyGenParams"); | 858 context.add("RsaHashedKeyGenParams"); |
| 823 return parseRsaHashedKeyGenParams(raw, params, context, result); | 859 return parseRsaHashedKeyGenParams(raw, params, context, result); |
| 824 case blink::WebCryptoAlgorithmParamsTypeRsaHashedImportParams: | 860 case blink::WebCryptoAlgorithmParamsTypeRsaHashedImportParams: |
| 825 context.add("RsaHashedImportParams"); | 861 context.add("RsaHashedImportParams"); |
| 826 return parseRsaHashedImportParams(raw, params, context, result); | 862 return parseRsaHashedImportParams(raw, params, context, result); |
| 863 case blink::WebCryptoAlgorithmParamsTypeRsaKeyGenParams: |
| 864 context.add("RsaKeyGenParams"); |
| 865 return parseRsaKeyGenParams(raw, params, context, result); |
| 827 case blink::WebCryptoAlgorithmParamsTypeAesCtrParams: | 866 case blink::WebCryptoAlgorithmParamsTypeAesCtrParams: |
| 828 context.add("AesCtrParams"); | 867 context.add("AesCtrParams"); |
| 829 return parseAesCtrParams(raw, params, context, result); | 868 return parseAesCtrParams(raw, params, context, result); |
| 830 case blink::WebCryptoAlgorithmParamsTypeAesGcmParams: | 869 case blink::WebCryptoAlgorithmParamsTypeAesGcmParams: |
| 831 context.add("AesGcmParams"); | 870 context.add("AesGcmParams"); |
| 832 return parseAesGcmParams(raw, params, context, result); | 871 return parseAesGcmParams(raw, params, context, result); |
| 833 case blink::WebCryptoAlgorithmParamsTypeRsaOaepParams: | 872 case blink::WebCryptoAlgorithmParamsTypeRsaOaepParams: |
| 834 context.add("RsaOaepParams"); | 873 context.add("RsaOaepParams"); |
| 835 return parseRsaOaepParams(raw, params, context, result); | 874 return parseRsaOaepParams(raw, params, context, result); |
| 836 break; | 875 break; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 { | 957 { |
| 919 return parseAlgorithm(raw, op, algorithm, ErrorContext(), result); | 958 return parseAlgorithm(raw, op, algorithm, ErrorContext(), result); |
| 920 } | 959 } |
| 921 | 960 |
| 922 const char* algorithmIdToName(blink::WebCryptoAlgorithmId id) | 961 const char* algorithmIdToName(blink::WebCryptoAlgorithmId id) |
| 923 { | 962 { |
| 924 return lookupAlgorithmInfo(id)->name; | 963 return lookupAlgorithmInfo(id)->name; |
| 925 } | 964 } |
| 926 | 965 |
| 927 } // namespace WebCore | 966 } // namespace WebCore |
| OLD | NEW |