| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 private: | 71 private: |
| 72 const WebVector<unsigned char> m_iv; | 72 const WebVector<unsigned char> m_iv; |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 class WebCryptoAlgorithmParamsWithHash : public WebCryptoAlgorithmParams { | 75 class WebCryptoAlgorithmParamsWithHash : public WebCryptoAlgorithmParams { |
| 76 public: | 76 public: |
| 77 explicit WebCryptoAlgorithmParamsWithHash(const WebCryptoAlgorithm& hash) | 77 explicit WebCryptoAlgorithmParamsWithHash(const WebCryptoAlgorithm& hash) |
| 78 : m_hash(hash) | 78 : m_hash(hash) |
| 79 { | 79 { |
| 80 BLINK_ASSERT(!hash.isNull()); | 80 DCHECK(!hash.isNull()); |
| 81 } | 81 } |
| 82 | 82 |
| 83 const WebCryptoAlgorithm& hash() const { return m_hash; } | 83 const WebCryptoAlgorithm& hash() const { return m_hash; } |
| 84 | 84 |
| 85 private: | 85 private: |
| 86 const WebCryptoAlgorithm m_hash; | 86 const WebCryptoAlgorithm m_hash; |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 class WebCryptoAesCtrParams : public WebCryptoAlgorithmParams { | 89 class WebCryptoAesCtrParams : public WebCryptoAlgorithmParams { |
| 90 public: | 90 public: |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 , m_hasLengthBits(false) | 128 , m_hasLengthBits(false) |
| 129 , m_optionalLengthBits(0) | 129 , m_optionalLengthBits(0) |
| 130 { | 130 { |
| 131 } | 131 } |
| 132 | 132 |
| 133 WebCryptoHmacImportParams(const WebCryptoAlgorithm& hash, bool hasLengthBits
, unsigned lengthBits) | 133 WebCryptoHmacImportParams(const WebCryptoAlgorithm& hash, bool hasLengthBits
, unsigned lengthBits) |
| 134 : WebCryptoAlgorithmParamsWithHash(hash) | 134 : WebCryptoAlgorithmParamsWithHash(hash) |
| 135 , m_hasLengthBits(hasLengthBits) | 135 , m_hasLengthBits(hasLengthBits) |
| 136 , m_optionalLengthBits(lengthBits) | 136 , m_optionalLengthBits(lengthBits) |
| 137 { | 137 { |
| 138 BLINK_ASSERT(hasLengthBits || !lengthBits); | 138 DCHECK(hasLengthBits || !lengthBits); |
| 139 } | 139 } |
| 140 | 140 |
| 141 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith
mParamsTypeHmacImportParams; } | 141 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith
mParamsTypeHmacImportParams; } |
| 142 | 142 |
| 143 bool hasLengthBits() const { return m_hasLengthBits; } | 143 bool hasLengthBits() const { return m_hasLengthBits; } |
| 144 | 144 |
| 145 unsigned optionalLengthBits() const { return m_optionalLengthBits; } | 145 unsigned optionalLengthBits() const { return m_optionalLengthBits; } |
| 146 | 146 |
| 147 private: | 147 private: |
| 148 const bool m_hasLengthBits; | 148 const bool m_hasLengthBits; |
| 149 const unsigned m_optionalLengthBits; | 149 const unsigned m_optionalLengthBits; |
| 150 }; | 150 }; |
| 151 | 151 |
| 152 class WebCryptoHmacKeyGenParams : public WebCryptoAlgorithmParamsWithHash { | 152 class WebCryptoHmacKeyGenParams : public WebCryptoAlgorithmParamsWithHash { |
| 153 public: | 153 public: |
| 154 WebCryptoHmacKeyGenParams(const WebCryptoAlgorithm& hash, bool hasLengthBits
, unsigned lengthBits) | 154 WebCryptoHmacKeyGenParams(const WebCryptoAlgorithm& hash, bool hasLengthBits
, unsigned lengthBits) |
| 155 : WebCryptoAlgorithmParamsWithHash(hash) | 155 : WebCryptoAlgorithmParamsWithHash(hash) |
| 156 , m_hasLengthBits(hasLengthBits) | 156 , m_hasLengthBits(hasLengthBits) |
| 157 , m_optionalLengthBits(lengthBits) | 157 , m_optionalLengthBits(lengthBits) |
| 158 { | 158 { |
| 159 BLINK_ASSERT(hasLengthBits || !lengthBits); | 159 DCHECK(hasLengthBits || !lengthBits); |
| 160 } | 160 } |
| 161 | 161 |
| 162 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith
mParamsTypeHmacKeyGenParams; } | 162 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith
mParamsTypeHmacKeyGenParams; } |
| 163 | 163 |
| 164 bool hasLengthBits() const { return m_hasLengthBits; } | 164 bool hasLengthBits() const { return m_hasLengthBits; } |
| 165 | 165 |
| 166 unsigned optionalLengthBits() const { return m_optionalLengthBits; } | 166 unsigned optionalLengthBits() const { return m_optionalLengthBits; } |
| 167 | 167 |
| 168 private: | 168 private: |
| 169 const bool m_hasLengthBits; | 169 const bool m_hasLengthBits; |
| 170 const unsigned m_optionalLengthBits; | 170 const unsigned m_optionalLengthBits; |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 class WebCryptoAesGcmParams : public WebCryptoAlgorithmParams { | 173 class WebCryptoAesGcmParams : public WebCryptoAlgorithmParams { |
| 174 public: | 174 public: |
| 175 WebCryptoAesGcmParams(const unsigned char* iv, unsigned ivSize, bool hasAddi
tionalData, const unsigned char* additionalData, unsigned additionalDataSize, bo
ol hasTagLengthBits, unsigned char tagLengthBits) | 175 WebCryptoAesGcmParams(const unsigned char* iv, unsigned ivSize, bool hasAddi
tionalData, const unsigned char* additionalData, unsigned additionalDataSize, bo
ol hasTagLengthBits, unsigned char tagLengthBits) |
| 176 : m_iv(iv, ivSize) | 176 : m_iv(iv, ivSize) |
| 177 , m_hasAdditionalData(hasAdditionalData) | 177 , m_hasAdditionalData(hasAdditionalData) |
| 178 , m_optionalAdditionalData(additionalData, additionalDataSize) | 178 , m_optionalAdditionalData(additionalData, additionalDataSize) |
| 179 , m_hasTagLengthBits(hasTagLengthBits) | 179 , m_hasTagLengthBits(hasTagLengthBits) |
| 180 , m_optionalTagLengthBits(tagLengthBits) | 180 , m_optionalTagLengthBits(tagLengthBits) |
| 181 { | 181 { |
| 182 BLINK_ASSERT(hasAdditionalData || !additionalDataSize); | 182 DCHECK(hasAdditionalData || !additionalDataSize); |
| 183 BLINK_ASSERT(hasTagLengthBits || !tagLengthBits); | 183 DCHECK(hasTagLengthBits || !tagLengthBits); |
| 184 } | 184 } |
| 185 | 185 |
| 186 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith
mParamsTypeAesGcmParams; } | 186 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith
mParamsTypeAesGcmParams; } |
| 187 | 187 |
| 188 const WebVector<unsigned char>& iv() const { return m_iv; } | 188 const WebVector<unsigned char>& iv() const { return m_iv; } |
| 189 | 189 |
| 190 bool hasAdditionalData() const { return m_hasAdditionalData; } | 190 bool hasAdditionalData() const { return m_hasAdditionalData; } |
| 191 const WebVector<unsigned char>& optionalAdditionalData() const { return m_op
tionalAdditionalData; } | 191 const WebVector<unsigned char>& optionalAdditionalData() const { return m_op
tionalAdditionalData; } |
| 192 | 192 |
| 193 bool hasTagLengthBits() const { return m_hasTagLengthBits; } | 193 bool hasTagLengthBits() const { return m_hasTagLengthBits; } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 211 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith
mParamsTypeRsaHashedImportParams; } | 211 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith
mParamsTypeRsaHashedImportParams; } |
| 212 }; | 212 }; |
| 213 | 213 |
| 214 class WebCryptoRsaHashedKeyGenParams : public WebCryptoAlgorithmParams { | 214 class WebCryptoRsaHashedKeyGenParams : public WebCryptoAlgorithmParams { |
| 215 public: | 215 public: |
| 216 explicit WebCryptoRsaHashedKeyGenParams(const WebCryptoAlgorithm& hash, unsi
gned modulusLengthBits, const unsigned char* publicExponent, unsigned publicExpo
nentSize) | 216 explicit WebCryptoRsaHashedKeyGenParams(const WebCryptoAlgorithm& hash, unsi
gned modulusLengthBits, const unsigned char* publicExponent, unsigned publicExpo
nentSize) |
| 217 : m_modulusLengthBits(modulusLengthBits) | 217 : m_modulusLengthBits(modulusLengthBits) |
| 218 , m_publicExponent(publicExponent, publicExponentSize) | 218 , m_publicExponent(publicExponent, publicExponentSize) |
| 219 , m_hash(hash) | 219 , m_hash(hash) |
| 220 { | 220 { |
| 221 BLINK_ASSERT(!hash.isNull()); | 221 DCHECK(!hash.isNull()); |
| 222 } | 222 } |
| 223 | 223 |
| 224 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith
mParamsTypeRsaHashedKeyGenParams; } | 224 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith
mParamsTypeRsaHashedKeyGenParams; } |
| 225 | 225 |
| 226 unsigned modulusLengthBits() const { return m_modulusLengthBits; } | 226 unsigned modulusLengthBits() const { return m_modulusLengthBits; } |
| 227 const WebVector<unsigned char>& publicExponent() const { return m_publicExpo
nent; } | 227 const WebVector<unsigned char>& publicExponent() const { return m_publicExpo
nent; } |
| 228 const WebCryptoAlgorithm& hash() const { return m_hash; } | 228 const WebCryptoAlgorithm& hash() const { return m_hash; } |
| 229 | 229 |
| 230 // Converts the public exponent (big-endian WebCrypto BigInteger), | 230 // Converts the public exponent (big-endian WebCrypto BigInteger), |
| 231 // with or without leading zeros, to unsigned int. Returns true on success. | 231 // with or without leading zeros, to unsigned int. Returns true on success. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 248 const WebVector<unsigned char> m_publicExponent; | 248 const WebVector<unsigned char> m_publicExponent; |
| 249 const WebCryptoAlgorithm m_hash; | 249 const WebCryptoAlgorithm m_hash; |
| 250 }; | 250 }; |
| 251 | 251 |
| 252 class WebCryptoRsaOaepParams : public WebCryptoAlgorithmParams { | 252 class WebCryptoRsaOaepParams : public WebCryptoAlgorithmParams { |
| 253 public: | 253 public: |
| 254 WebCryptoRsaOaepParams(bool hasLabel, const unsigned char* label, unsigned l
abelSize) | 254 WebCryptoRsaOaepParams(bool hasLabel, const unsigned char* label, unsigned l
abelSize) |
| 255 : m_hasLabel(hasLabel) | 255 : m_hasLabel(hasLabel) |
| 256 , m_optionalLabel(label, labelSize) | 256 , m_optionalLabel(label, labelSize) |
| 257 { | 257 { |
| 258 BLINK_ASSERT(hasLabel || !labelSize); | 258 DCHECK(hasLabel || !labelSize); |
| 259 } | 259 } |
| 260 | 260 |
| 261 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith
mParamsTypeRsaOaepParams; } | 261 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith
mParamsTypeRsaOaepParams; } |
| 262 | 262 |
| 263 bool hasLabel() const { return m_hasLabel; } | 263 bool hasLabel() const { return m_hasLabel; } |
| 264 const WebVector<unsigned char>& optionalLabel() const { return m_optionalLab
el; } | 264 const WebVector<unsigned char>& optionalLabel() const { return m_optionalLab
el; } |
| 265 | 265 |
| 266 private: | 266 private: |
| 267 const bool m_hasLabel; | 267 const bool m_hasLabel; |
| 268 const WebVector<unsigned char> m_optionalLabel; | 268 const WebVector<unsigned char> m_optionalLabel; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 unsigned iterations() const { return m_iterations; } | 391 unsigned iterations() const { return m_iterations; } |
| 392 | 392 |
| 393 private: | 393 private: |
| 394 const WebVector<unsigned char> m_salt; | 394 const WebVector<unsigned char> m_salt; |
| 395 const unsigned m_iterations; | 395 const unsigned m_iterations; |
| 396 }; | 396 }; |
| 397 | 397 |
| 398 } // namespace blink | 398 } // namespace blink |
| 399 | 399 |
| 400 #endif | 400 #endif |
| OLD | NEW |