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

Side by Side Diff: Source/modules/crypto/NormalizeAlgorithm.cpp

Issue 23441021: WebCrypto: Add algorithm normalization rules for RSAES-PKCS1-v1_5. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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 | « LayoutTests/crypto/sign-verify-expected.txt ('k') | public/platform/WebCryptoAlgorithm.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 struct OperationParamsMapping { 63 struct OperationParamsMapping {
64 WebKit::WebCryptoAlgorithmId algorithmId; 64 WebKit::WebCryptoAlgorithmId algorithmId;
65 AlgorithmOperation operation; 65 AlgorithmOperation operation;
66 AlgorithmParamsForOperation params; 66 AlgorithmParamsForOperation params;
67 }; 67 };
68 68
69 const AlgorithmNameMapping algorithmNameMappings[] = { 69 const AlgorithmNameMapping algorithmNameMappings[] = {
70 {"AES-CBC", WebKit::WebCryptoAlgorithmIdAesCbc}, 70 {"AES-CBC", WebKit::WebCryptoAlgorithmIdAesCbc},
71 {"HMAC", WebKit::WebCryptoAlgorithmIdHmac}, 71 {"HMAC", WebKit::WebCryptoAlgorithmIdHmac},
72 {"RSASSA-PKCS1-v1_5", WebKit::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5}, 72 {"RSASSA-PKCS1-v1_5", WebKit::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5},
73 {"RSAES-PKCS1-v1_5", WebKit::WebCryptoAlgorithmIdRsaEsPkcs1v1_5},
73 {"SHA-1", WebKit::WebCryptoAlgorithmIdSha1}, 74 {"SHA-1", WebKit::WebCryptoAlgorithmIdSha1},
74 {"SHA-224", WebKit::WebCryptoAlgorithmIdSha224}, 75 {"SHA-224", WebKit::WebCryptoAlgorithmIdSha224},
75 {"SHA-256", WebKit::WebCryptoAlgorithmIdSha256}, 76 {"SHA-256", WebKit::WebCryptoAlgorithmIdSha256},
76 {"SHA-384", WebKit::WebCryptoAlgorithmIdSha384}, 77 {"SHA-384", WebKit::WebCryptoAlgorithmIdSha384},
77 {"SHA-512", WebKit::WebCryptoAlgorithmIdSha512}, 78 {"SHA-512", WebKit::WebCryptoAlgorithmIdSha512},
78 }; 79 };
79 80
80 // What operations each algorithm supports, and what parameters it expects. 81 // What operations each algorithm supports, and what parameters it expects.
81 const OperationParamsMapping operationParamsMappings[] = { 82 const OperationParamsMapping operationParamsMappings[] = {
82 // AES-CBC 83 // AES-CBC
83 {WebKit::WebCryptoAlgorithmIdAesCbc, Decrypt, WebKit::WebCryptoAlgorithmPara msTypeAesCbcParams}, 84 {WebKit::WebCryptoAlgorithmIdAesCbc, Decrypt, WebKit::WebCryptoAlgorithmPara msTypeAesCbcParams},
84 {WebKit::WebCryptoAlgorithmIdAesCbc, Encrypt, WebKit::WebCryptoAlgorithmPara msTypeAesCbcParams}, 85 {WebKit::WebCryptoAlgorithmIdAesCbc, Encrypt, WebKit::WebCryptoAlgorithmPara msTypeAesCbcParams},
85 {WebKit::WebCryptoAlgorithmIdAesCbc, GenerateKey, WebKit::WebCryptoAlgorithm ParamsTypeAesKeyGenParams}, 86 {WebKit::WebCryptoAlgorithmIdAesCbc, GenerateKey, WebKit::WebCryptoAlgorithm ParamsTypeAesKeyGenParams},
86 {WebKit::WebCryptoAlgorithmIdAesCbc, ImportKey, WebKit::WebCryptoAlgorithmPa ramsTypeNone}, 87 {WebKit::WebCryptoAlgorithmIdAesCbc, ImportKey, WebKit::WebCryptoAlgorithmPa ramsTypeNone},
87 88
88 // HMAC 89 // HMAC
89 {WebKit::WebCryptoAlgorithmIdHmac, Sign, WebKit::WebCryptoAlgorithmParamsTyp eHmacParams}, 90 {WebKit::WebCryptoAlgorithmIdHmac, Sign, WebKit::WebCryptoAlgorithmParamsTyp eHmacParams},
90 {WebKit::WebCryptoAlgorithmIdHmac, Verify, WebKit::WebCryptoAlgorithmParamsT ypeHmacParams}, 91 {WebKit::WebCryptoAlgorithmIdHmac, Verify, WebKit::WebCryptoAlgorithmParamsT ypeHmacParams},
91 {WebKit::WebCryptoAlgorithmIdHmac, GenerateKey, WebKit::WebCryptoAlgorithmPa ramsTypeHmacKeyParams}, 92 {WebKit::WebCryptoAlgorithmIdHmac, GenerateKey, WebKit::WebCryptoAlgorithmPa ramsTypeHmacKeyParams},
92 {WebKit::WebCryptoAlgorithmIdHmac, ImportKey, WebKit::WebCryptoAlgorithmPara msTypeHmacParams}, 93 {WebKit::WebCryptoAlgorithmIdHmac, ImportKey, WebKit::WebCryptoAlgorithmPara msTypeHmacParams},
93 94
94 // RSASSA-PKCS1-v1_5 95 // RSASSA-PKCS1-v1_5
95 {WebKit::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, Sign, WebKit::WebCryptoAlgorit hmParamsTypeRsaSsaParams}, 96 {WebKit::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, Sign, WebKit::WebCryptoAlgorit hmParamsTypeRsaSsaParams},
96 {WebKit::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, Verify, WebKit::WebCryptoAlgor ithmParamsTypeRsaSsaParams}, 97 {WebKit::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, Verify, WebKit::WebCryptoAlgor ithmParamsTypeRsaSsaParams},
97 {WebKit::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, GenerateKey, WebKit::WebCrypto AlgorithmParamsTypeRsaKeyGenParams}, 98 {WebKit::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, GenerateKey, WebKit::WebCrypto AlgorithmParamsTypeRsaKeyGenParams},
98 {WebKit::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, ImportKey, WebKit::WebCryptoAl gorithmParamsTypeNone}, 99 {WebKit::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, ImportKey, WebKit::WebCryptoAl gorithmParamsTypeNone},
99 100
101 // RSAES-PKCS1-v1_5
102 {WebKit::WebCryptoAlgorithmIdRsaEsPkcs1v1_5, Encrypt, WebKit::WebCryptoAlgor ithmParamsTypeNone},
103 {WebKit::WebCryptoAlgorithmIdRsaEsPkcs1v1_5, Decrypt, WebKit::WebCryptoAlgor ithmParamsTypeNone},
104 {WebKit::WebCryptoAlgorithmIdRsaEsPkcs1v1_5, GenerateKey, WebKit::WebCryptoA lgorithmParamsTypeRsaKeyGenParams},
105 {WebKit::WebCryptoAlgorithmIdRsaEsPkcs1v1_5, ImportKey, WebKit::WebCryptoAlg orithmParamsTypeNone},
106
100 // SHA-* 107 // SHA-*
101 {WebKit::WebCryptoAlgorithmIdSha1, Digest, WebKit::WebCryptoAlgorithmParamsT ypeNone}, 108 {WebKit::WebCryptoAlgorithmIdSha1, Digest, WebKit::WebCryptoAlgorithmParamsT ypeNone},
102 {WebKit::WebCryptoAlgorithmIdSha224, Digest, WebKit::WebCryptoAlgorithmParam sTypeNone}, 109 {WebKit::WebCryptoAlgorithmIdSha224, Digest, WebKit::WebCryptoAlgorithmParam sTypeNone},
103 {WebKit::WebCryptoAlgorithmIdSha256, Digest, WebKit::WebCryptoAlgorithmParam sTypeNone}, 110 {WebKit::WebCryptoAlgorithmIdSha256, Digest, WebKit::WebCryptoAlgorithmParam sTypeNone},
104 {WebKit::WebCryptoAlgorithmIdSha384, Digest, WebKit::WebCryptoAlgorithmParam sTypeNone}, 111 {WebKit::WebCryptoAlgorithmIdSha384, Digest, WebKit::WebCryptoAlgorithmParam sTypeNone},
105 {WebKit::WebCryptoAlgorithmIdSha512, Digest, WebKit::WebCryptoAlgorithmParam sTypeNone}, 112 {WebKit::WebCryptoAlgorithmIdSha512, Digest, WebKit::WebCryptoAlgorithmParam sTypeNone},
106 }; 113 };
107 114
108 // This structure describes an algorithm and its supported operations. 115 // This structure describes an algorithm and its supported operations.
109 struct AlgorithmInfo { 116 struct AlgorithmInfo {
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 } 474 }
468 475
469 } // namespace 476 } // namespace
470 477
471 bool normalizeAlgorithm(const Dictionary& raw, AlgorithmOperation op, WebKit::We bCryptoAlgorithm& algorithm, ExceptionState& es) 478 bool normalizeAlgorithm(const Dictionary& raw, AlgorithmOperation op, WebKit::We bCryptoAlgorithm& algorithm, ExceptionState& es)
472 { 479 {
473 return normalizeAlgorithm(raw, op, algorithm, ExceptionContext(), es); 480 return normalizeAlgorithm(raw, op, algorithm, ExceptionContext(), es);
474 } 481 }
475 482
476 } // namespace WebCore 483 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/crypto/sign-verify-expected.txt ('k') | public/platform/WebCryptoAlgorithm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698