OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 return WebCryptoKeyAlgorithm(id, adoptPtr(new WebCryptoAesKeyAlgorithmParams
(keyLengthBits))); | 73 return WebCryptoKeyAlgorithm(id, adoptPtr(new WebCryptoAesKeyAlgorithmParams
(keyLengthBits))); |
74 } | 74 } |
75 | 75 |
76 WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::createHmac(WebCryptoAlgorithmId has
h, unsigned keyLengthBits) | 76 WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::createHmac(WebCryptoAlgorithmId has
h, unsigned keyLengthBits) |
77 { | 77 { |
78 if (!WebCryptoAlgorithm::isHash(hash)) | 78 if (!WebCryptoAlgorithm::isHash(hash)) |
79 return WebCryptoKeyAlgorithm(); | 79 return WebCryptoKeyAlgorithm(); |
80 return WebCryptoKeyAlgorithm(WebCryptoAlgorithmIdHmac, adoptPtr(new WebCrypt
oHmacKeyAlgorithmParams(createHash(hash), keyLengthBits))); | 80 return WebCryptoKeyAlgorithm(WebCryptoAlgorithmIdHmac, adoptPtr(new WebCrypt
oHmacKeyAlgorithmParams(createHash(hash), keyLengthBits))); |
81 } | 81 } |
82 | 82 |
| 83 WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::createRsa(WebCryptoAlgorithmId id,
unsigned modulusLengthBits, const unsigned char* publicExponent, unsigned public
ExponentSize) |
| 84 { |
| 85 // FIXME: Verify that id is an RSA algorithm without a hash |
| 86 return WebCryptoKeyAlgorithm(id, adoptPtr(new WebCryptoRsaKeyAlgorithmParams
(modulusLengthBits, publicExponent, publicExponentSize))); |
| 87 } |
| 88 |
83 WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::createRsaHashed(WebCryptoAlgorithmI
d id, unsigned modulusLengthBits, const unsigned char* publicExponent, unsigned
publicExponentSize, WebCryptoAlgorithmId hash) | 89 WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::createRsaHashed(WebCryptoAlgorithmI
d id, unsigned modulusLengthBits, const unsigned char* publicExponent, unsigned
publicExponentSize, WebCryptoAlgorithmId hash) |
84 { | 90 { |
85 // FIXME: Verify that id is an RSA algorithm which expects a hash | 91 // FIXME: Verify that id is an RSA algorithm which expects a hash |
86 if (!WebCryptoAlgorithm::isHash(hash)) | 92 if (!WebCryptoAlgorithm::isHash(hash)) |
87 return WebCryptoKeyAlgorithm(); | 93 return WebCryptoKeyAlgorithm(); |
88 return WebCryptoKeyAlgorithm(id, adoptPtr(new WebCryptoRsaHashedKeyAlgorithm
Params(modulusLengthBits, publicExponent, publicExponentSize, createHash(hash)))
); | 94 return WebCryptoKeyAlgorithm(id, adoptPtr(new WebCryptoRsaHashedKeyAlgorithm
Params(modulusLengthBits, publicExponent, publicExponentSize, createHash(hash)))
); |
89 } | 95 } |
90 | 96 |
91 bool WebCryptoKeyAlgorithm::isNull() const | 97 bool WebCryptoKeyAlgorithm::isNull() const |
92 { | 98 { |
(...skipping 23 matching lines...) Expand all Loading... |
116 } | 122 } |
117 | 123 |
118 WebCryptoHmacKeyAlgorithmParams* WebCryptoKeyAlgorithm::hmacParams() const | 124 WebCryptoHmacKeyAlgorithmParams* WebCryptoKeyAlgorithm::hmacParams() const |
119 { | 125 { |
120 ASSERT(!isNull()); | 126 ASSERT(!isNull()); |
121 if (paramsType() == WebCryptoKeyAlgorithmParamsTypeHmac) | 127 if (paramsType() == WebCryptoKeyAlgorithmParamsTypeHmac) |
122 return static_cast<WebCryptoHmacKeyAlgorithmParams*>(m_private->params.g
et()); | 128 return static_cast<WebCryptoHmacKeyAlgorithmParams*>(m_private->params.g
et()); |
123 return 0; | 129 return 0; |
124 } | 130 } |
125 | 131 |
| 132 WebCryptoRsaKeyAlgorithmParams* WebCryptoKeyAlgorithm::rsaParams() const |
| 133 { |
| 134 ASSERT(!isNull()); |
| 135 if (paramsType() == WebCryptoKeyAlgorithmParamsTypeRsa || paramsType() == We
bCryptoKeyAlgorithmParamsTypeRsaHashed) |
| 136 return static_cast<WebCryptoRsaKeyAlgorithmParams*>(m_private->params.ge
t()); |
| 137 return 0; |
| 138 } |
| 139 |
126 WebCryptoRsaHashedKeyAlgorithmParams* WebCryptoKeyAlgorithm::rsaHashedParams() c
onst | 140 WebCryptoRsaHashedKeyAlgorithmParams* WebCryptoKeyAlgorithm::rsaHashedParams() c
onst |
127 { | 141 { |
128 ASSERT(!isNull()); | 142 ASSERT(!isNull()); |
129 if (paramsType() == WebCryptoKeyAlgorithmParamsTypeRsaHashed) | 143 if (paramsType() == WebCryptoKeyAlgorithmParamsTypeRsaHashed) |
130 return static_cast<WebCryptoRsaHashedKeyAlgorithmParams*>(m_private->par
ams.get()); | 144 return static_cast<WebCryptoRsaHashedKeyAlgorithmParams*>(m_private->par
ams.get()); |
131 return 0; | 145 return 0; |
132 } | 146 } |
133 | 147 |
134 void WebCryptoKeyAlgorithm::assign(const WebCryptoKeyAlgorithm& other) | 148 void WebCryptoKeyAlgorithm::assign(const WebCryptoKeyAlgorithm& other) |
135 { | 149 { |
136 m_private = other.m_private; | 150 m_private = other.m_private; |
137 } | 151 } |
138 | 152 |
139 void WebCryptoKeyAlgorithm::reset() | 153 void WebCryptoKeyAlgorithm::reset() |
140 { | 154 { |
141 m_private.reset(); | 155 m_private.reset(); |
142 } | 156 } |
143 | 157 |
144 } // namespace blink | 158 } // namespace blink |
OLD | NEW |