| 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 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 // NOTE: For documentation on the meaning of each of the parameters see the | 40 // NOTE: For documentation on the meaning of each of the parameters see the |
| 41 // Web crypto spec: | 41 // Web crypto spec: |
| 42 // | 42 // |
| 43 // http://www.w3.org/TR/WebCryptoAPI | 43 // http://www.w3.org/TR/WebCryptoAPI |
| 44 // | 44 // |
| 45 // The parameters in the spec have the same name, minus the "WebCrypto" pr
efix. | 45 // The parameters in the spec have the same name, minus the "WebCrypto" pr
efix. |
| 46 | 46 |
| 47 class WebCryptoAlgorithmParams { | 47 class WebCryptoAlgorithmParams { |
| 48 public: | 48 public: |
| 49 WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsType type) | 49 explicit WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsType type) |
| 50 : m_type(type) | 50 : m_type(type) |
| 51 { | 51 { |
| 52 } | 52 } |
| 53 | 53 |
| 54 virtual ~WebCryptoAlgorithmParams() { } | 54 virtual ~WebCryptoAlgorithmParams() { } |
| 55 | 55 |
| 56 WebCryptoAlgorithmParamsType type() const { return m_type; } | 56 WebCryptoAlgorithmParamsType type() const { return m_type; } |
| 57 | 57 |
| 58 private: | 58 private: |
| 59 WebCryptoAlgorithmParamsType m_type; | 59 WebCryptoAlgorithmParamsType m_type; |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 class WebCryptoAesCbcParams : public WebCryptoAlgorithmParams { | 62 class WebCryptoAesCbcParams : public WebCryptoAlgorithmParams { |
| 63 public: | 63 public: |
| 64 WebCryptoAesCbcParams(unsigned char* iv, size_t ivSize) | 64 WebCryptoAesCbcParams(unsigned char* iv, size_t ivSize) |
| 65 : WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsTypeAesCbcParams) | 65 : WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsTypeAesCbcParams) |
| 66 , m_iv(iv, ivSize) | 66 , m_iv(iv, ivSize) |
| 67 { | 67 { |
| 68 } | 68 } |
| 69 | 69 |
| 70 const WebVector<unsigned char>& iv() const { return m_iv; } | 70 const WebVector<unsigned char>& iv() const { return m_iv; } |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 const WebVector<unsigned char> m_iv; | 73 const WebVector<unsigned char> m_iv; |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 class WebCryptoAesKeyGenParams : public WebCryptoAlgorithmParams { | 76 class WebCryptoAesKeyGenParams : public WebCryptoAlgorithmParams { |
| 77 public: | 77 public: |
| 78 WebCryptoAesKeyGenParams(unsigned short length) | 78 explicit WebCryptoAesKeyGenParams(unsigned short length) |
| 79 : WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsTypeAesKeyGenParams) | 79 : WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsTypeAesKeyGenParams) |
| 80 , m_length(length) | 80 , m_length(length) |
| 81 { | 81 { |
| 82 } | 82 } |
| 83 | 83 |
| 84 unsigned short length() const { return m_length; } | 84 unsigned short length() const { return m_length; } |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 const unsigned short m_length; | 87 const unsigned short m_length; |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 class WebCryptoHmacParams : public WebCryptoAlgorithmParams { | 90 class WebCryptoHmacParams : public WebCryptoAlgorithmParams { |
| 91 public: | 91 public: |
| 92 WebCryptoHmacParams(const WebCryptoAlgorithm& hash) | 92 explicit WebCryptoHmacParams(const WebCryptoAlgorithm& hash) |
| 93 : WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsTypeHmacParams) | 93 : WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsTypeHmacParams) |
| 94 , m_hash(hash) | 94 , m_hash(hash) |
| 95 { | 95 { |
| 96 } | 96 } |
| 97 | 97 |
| 98 const WebCryptoAlgorithm& hash() const { return m_hash; } | 98 const WebCryptoAlgorithm& hash() const { return m_hash; } |
| 99 | 99 |
| 100 private: | 100 private: |
| 101 WebCryptoAlgorithm m_hash; | 101 WebCryptoAlgorithm m_hash; |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 class WebCryptoRsaSsaParams : public WebCryptoAlgorithmParams { |
| 105 public: |
| 106 explicit WebCryptoRsaSsaParams(const WebCryptoAlgorithm& hash) |
| 107 : WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsTypeRsaSsaParams) |
| 108 , m_hash(hash) |
| 109 { |
| 110 } |
| 111 |
| 112 const WebCryptoAlgorithm& hash() const { return m_hash; } |
| 113 |
| 114 private: |
| 115 WebCryptoAlgorithm m_hash; |
| 116 }; |
| 117 |
| 118 class WebCryptoRsaKeyGenParams : public WebCryptoAlgorithmParams { |
| 119 public: |
| 120 WebCryptoRsaKeyGenParams(unsigned modulusLength, const unsigned char* public
Exponent, size_t publicExponentSize) |
| 121 : WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsTypeRsaKeyGenParams) |
| 122 , m_modulusLength(modulusLength) |
| 123 , m_publicExponent(publicExponent, publicExponentSize) |
| 124 { |
| 125 } |
| 126 |
| 127 unsigned modulusLength() const { return m_modulusLength; } |
| 128 const WebVector<unsigned char>& publicExponent() const { return m_publicExpo
nent; } |
| 129 |
| 130 private: |
| 131 const unsigned m_modulusLength; |
| 132 const WebVector<unsigned char> m_publicExponent; |
| 133 }; |
| 134 |
| 104 } // namespace WebKit | 135 } // namespace WebKit |
| 105 | 136 |
| 106 #endif | 137 #endif |
| OLD | NEW |