| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 } | 81 } |
| 82 | 82 |
| 83 WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::createRsaHashed(WebCryptoAlgorithmI
d id, unsigned modulusLengthBits, const unsigned char* publicExponent, unsigned
publicExponentSize, WebCryptoAlgorithmId hash) | 83 WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::createRsaHashed(WebCryptoAlgorithmI
d id, unsigned modulusLengthBits, const unsigned char* publicExponent, unsigned
publicExponentSize, WebCryptoAlgorithmId hash) |
| 84 { | 84 { |
| 85 // FIXME: Verify that id is an RSA algorithm which expects a hash | 85 // FIXME: Verify that id is an RSA algorithm which expects a hash |
| 86 if (!WebCryptoAlgorithm::isHash(hash)) | 86 if (!WebCryptoAlgorithm::isHash(hash)) |
| 87 return WebCryptoKeyAlgorithm(); | 87 return WebCryptoKeyAlgorithm(); |
| 88 return WebCryptoKeyAlgorithm(id, adoptPtr(new WebCryptoRsaHashedKeyAlgorithm
Params(modulusLengthBits, publicExponent, publicExponentSize, createHash(hash)))
); | 88 return WebCryptoKeyAlgorithm(id, adoptPtr(new WebCryptoRsaHashedKeyAlgorithm
Params(modulusLengthBits, publicExponent, publicExponentSize, createHash(hash)))
); |
| 89 } | 89 } |
| 90 | 90 |
| 91 WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::createEc(WebCryptoAlgorithmId id, W
ebCryptoNamedCurve namedCurve) |
| 92 { |
| 93 return WebCryptoKeyAlgorithm(id, adoptPtr(new WebCryptoEcKeyAlgorithmParams(
namedCurve))); |
| 94 } |
| 95 |
| 91 bool WebCryptoKeyAlgorithm::isNull() const | 96 bool WebCryptoKeyAlgorithm::isNull() const |
| 92 { | 97 { |
| 93 return m_private.isNull(); | 98 return m_private.isNull(); |
| 94 } | 99 } |
| 95 | 100 |
| 96 WebCryptoAlgorithmId WebCryptoKeyAlgorithm::id() const | 101 WebCryptoAlgorithmId WebCryptoKeyAlgorithm::id() const |
| 97 { | 102 { |
| 98 ASSERT(!isNull()); | 103 ASSERT(!isNull()); |
| 99 return m_private->id; | 104 return m_private->id; |
| 100 } | 105 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 124 } | 129 } |
| 125 | 130 |
| 126 WebCryptoRsaHashedKeyAlgorithmParams* WebCryptoKeyAlgorithm::rsaHashedParams() c
onst | 131 WebCryptoRsaHashedKeyAlgorithmParams* WebCryptoKeyAlgorithm::rsaHashedParams() c
onst |
| 127 { | 132 { |
| 128 ASSERT(!isNull()); | 133 ASSERT(!isNull()); |
| 129 if (paramsType() == WebCryptoKeyAlgorithmParamsTypeRsaHashed) | 134 if (paramsType() == WebCryptoKeyAlgorithmParamsTypeRsaHashed) |
| 130 return static_cast<WebCryptoRsaHashedKeyAlgorithmParams*>(m_private->par
ams.get()); | 135 return static_cast<WebCryptoRsaHashedKeyAlgorithmParams*>(m_private->par
ams.get()); |
| 131 return 0; | 136 return 0; |
| 132 } | 137 } |
| 133 | 138 |
| 139 WebCryptoEcKeyAlgorithmParams* WebCryptoKeyAlgorithm::ecParams() const |
| 140 { |
| 141 ASSERT(!isNull()); |
| 142 if (paramsType() == WebCryptoKeyAlgorithmParamsTypeEc) |
| 143 return static_cast<WebCryptoEcKeyAlgorithmParams*>(m_private->params.get
()); |
| 144 return 0; |
| 145 } |
| 146 |
| 134 void WebCryptoKeyAlgorithm::writeToDictionary(WebCryptoKeyAlgorithmDictionary* d
ict) const | 147 void WebCryptoKeyAlgorithm::writeToDictionary(WebCryptoKeyAlgorithmDictionary* d
ict) const |
| 135 { | 148 { |
| 136 ASSERT(!isNull()); | 149 ASSERT(!isNull()); |
| 137 dict->setString("name", WebCryptoAlgorithm::lookupAlgorithmInfo(id())->name)
; | 150 dict->setString("name", WebCryptoAlgorithm::lookupAlgorithmInfo(id())->name)
; |
| 138 m_private->params.get()->writeToDictionary(dict); | 151 m_private->params.get()->writeToDictionary(dict); |
| 139 } | 152 } |
| 140 | 153 |
| 141 void WebCryptoKeyAlgorithm::assign(const WebCryptoKeyAlgorithm& other) | 154 void WebCryptoKeyAlgorithm::assign(const WebCryptoKeyAlgorithm& other) |
| 142 { | 155 { |
| 143 m_private = other.m_private; | 156 m_private = other.m_private; |
| 144 } | 157 } |
| 145 | 158 |
| 146 void WebCryptoKeyAlgorithm::reset() | 159 void WebCryptoKeyAlgorithm::reset() |
| 147 { | 160 { |
| 148 m_private.reset(); | 161 m_private.reset(); |
| 149 } | 162 } |
| 150 | 163 |
| 151 } // namespace blink | 164 } // namespace blink |
| OLD | NEW |