| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 } | 66 } |
| 67 | 67 |
| 68 WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::createAes( | 68 WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::createAes( |
| 69 WebCryptoAlgorithmId id, | 69 WebCryptoAlgorithmId id, |
| 70 unsigned short keyLengthBits) { | 70 unsigned short keyLengthBits) { |
| 71 // FIXME: Verify that id is an AES algorithm. | 71 // FIXME: Verify that id is an AES algorithm. |
| 72 // FIXME: Move this somewhere more general. | 72 // FIXME: Move this somewhere more general. |
| 73 if (keyLengthBits != 128 && keyLengthBits != 192 && keyLengthBits != 256) | 73 if (keyLengthBits != 128 && keyLengthBits != 192 && keyLengthBits != 256) |
| 74 return WebCryptoKeyAlgorithm(); | 74 return WebCryptoKeyAlgorithm(); |
| 75 return WebCryptoKeyAlgorithm( | 75 return WebCryptoKeyAlgorithm( |
| 76 id, wrapUnique(new WebCryptoAesKeyAlgorithmParams(keyLengthBits))); | 76 id, makeUnique<WebCryptoAesKeyAlgorithmParams>(keyLengthBits)); |
| 77 } | 77 } |
| 78 | 78 |
| 79 WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::createHmac( | 79 WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::createHmac( |
| 80 WebCryptoAlgorithmId hash, | 80 WebCryptoAlgorithmId hash, |
| 81 unsigned keyLengthBits) { | 81 unsigned keyLengthBits) { |
| 82 if (!WebCryptoAlgorithm::isHash(hash)) | 82 if (!WebCryptoAlgorithm::isHash(hash)) |
| 83 return WebCryptoKeyAlgorithm(); | 83 return WebCryptoKeyAlgorithm(); |
| 84 return WebCryptoKeyAlgorithm(WebCryptoAlgorithmIdHmac, | 84 return WebCryptoKeyAlgorithm(WebCryptoAlgorithmIdHmac, |
| 85 wrapUnique(new WebCryptoHmacKeyAlgorithmParams( | 85 wrapUnique(new WebCryptoHmacKeyAlgorithmParams( |
| 86 createHash(hash), keyLengthBits))); | 86 createHash(hash), keyLengthBits))); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 98 return WebCryptoKeyAlgorithm( | 98 return WebCryptoKeyAlgorithm( |
| 99 id, wrapUnique(new WebCryptoRsaHashedKeyAlgorithmParams( | 99 id, wrapUnique(new WebCryptoRsaHashedKeyAlgorithmParams( |
| 100 modulusLengthBits, publicExponent, publicExponentSize, | 100 modulusLengthBits, publicExponent, publicExponentSize, |
| 101 createHash(hash)))); | 101 createHash(hash)))); |
| 102 } | 102 } |
| 103 | 103 |
| 104 WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::createEc( | 104 WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::createEc( |
| 105 WebCryptoAlgorithmId id, | 105 WebCryptoAlgorithmId id, |
| 106 WebCryptoNamedCurve namedCurve) { | 106 WebCryptoNamedCurve namedCurve) { |
| 107 return WebCryptoKeyAlgorithm( | 107 return WebCryptoKeyAlgorithm( |
| 108 id, wrapUnique(new WebCryptoEcKeyAlgorithmParams(namedCurve))); | 108 id, makeUnique<WebCryptoEcKeyAlgorithmParams>(namedCurve)); |
| 109 } | 109 } |
| 110 | 110 |
| 111 WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::createWithoutParams( | 111 WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::createWithoutParams( |
| 112 WebCryptoAlgorithmId id) { | 112 WebCryptoAlgorithmId id) { |
| 113 if (!WebCryptoAlgorithm::isKdf(id)) | 113 if (!WebCryptoAlgorithm::isKdf(id)) |
| 114 return WebCryptoKeyAlgorithm(); | 114 return WebCryptoKeyAlgorithm(); |
| 115 return WebCryptoKeyAlgorithm(id, nullptr); | 115 return WebCryptoKeyAlgorithm(id, nullptr); |
| 116 } | 116 } |
| 117 | 117 |
| 118 bool WebCryptoKeyAlgorithm::isNull() const { | 118 bool WebCryptoKeyAlgorithm::isNull() const { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 173 |
| 174 void WebCryptoKeyAlgorithm::assign(const WebCryptoKeyAlgorithm& other) { | 174 void WebCryptoKeyAlgorithm::assign(const WebCryptoKeyAlgorithm& other) { |
| 175 m_private = other.m_private; | 175 m_private = other.m_private; |
| 176 } | 176 } |
| 177 | 177 |
| 178 void WebCryptoKeyAlgorithm::reset() { | 178 void WebCryptoKeyAlgorithm::reset() { |
| 179 m_private.reset(); | 179 m_private.reset(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 } // namespace blink | 182 } // namespace blink |
| OLD | NEW |