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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 WebCryptoAlgorithmParamsTypeAesKeyGenParams, | 78 WebCryptoAlgorithmParamsTypeAesKeyGenParams, |
79 WebCryptoAlgorithmParamsTypeHmacImportParams, | 79 WebCryptoAlgorithmParamsTypeHmacImportParams, |
80 WebCryptoAlgorithmParamsTypeHmacKeyGenParams, | 80 WebCryptoAlgorithmParamsTypeHmacKeyGenParams, |
81 WebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams, | 81 WebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams, |
82 WebCryptoAlgorithmParamsTypeRsaHashedImportParams, | 82 WebCryptoAlgorithmParamsTypeRsaHashedImportParams, |
83 WebCryptoAlgorithmParamsTypeAesGcmParams, | 83 WebCryptoAlgorithmParamsTypeAesGcmParams, |
84 WebCryptoAlgorithmParamsTypeRsaOaepParams, | 84 WebCryptoAlgorithmParamsTypeRsaOaepParams, |
85 WebCryptoAlgorithmParamsTypeAesCtrParams, | 85 WebCryptoAlgorithmParamsTypeAesCtrParams, |
86 }; | 86 }; |
87 | 87 |
| 88 struct WebCryptoAlgorithmInfo { |
| 89 typedef char ParamsTypeOrUndefined; |
| 90 static const ParamsTypeOrUndefined Undefined = -1; |
| 91 |
| 92 // The canonical (case-sensitive) name for the algorithm. |
| 93 const char* name; |
| 94 |
| 95 // A map from the operation to the expected parameter type of the algorithm. |
| 96 // If an operation is not applicable for the algorithm, set to Undefined. |
| 97 const ParamsTypeOrUndefined operationToParamsType[WebCryptoOperationLast + 1
]; |
| 98 }; |
| 99 |
| 100 |
88 class WebCryptoAesCbcParams; | 101 class WebCryptoAesCbcParams; |
89 class WebCryptoAesKeyGenParams; | 102 class WebCryptoAesKeyGenParams; |
90 class WebCryptoHmacImportParams; | 103 class WebCryptoHmacImportParams; |
91 class WebCryptoHmacKeyGenParams; | 104 class WebCryptoHmacKeyGenParams; |
92 class WebCryptoAesGcmParams; | 105 class WebCryptoAesGcmParams; |
93 class WebCryptoRsaOaepParams; | 106 class WebCryptoRsaOaepParams; |
94 class WebCryptoAesCtrParams; | 107 class WebCryptoAesCtrParams; |
95 class WebCryptoRsaHashedKeyGenParams; | 108 class WebCryptoRsaHashedKeyGenParams; |
96 class WebCryptoRsaHashedImportParams; | 109 class WebCryptoRsaHashedImportParams; |
97 | 110 |
(...skipping 10 matching lines...) Expand all Loading... |
108 class WebCryptoAlgorithm { | 121 class WebCryptoAlgorithm { |
109 public: | 122 public: |
110 #if INSIDE_BLINK | 123 #if INSIDE_BLINK |
111 WebCryptoAlgorithm() { } | 124 WebCryptoAlgorithm() { } |
112 BLINK_PLATFORM_EXPORT WebCryptoAlgorithm(WebCryptoAlgorithmId, PassOwnPtr<We
bCryptoAlgorithmParams>); | 125 BLINK_PLATFORM_EXPORT WebCryptoAlgorithm(WebCryptoAlgorithmId, PassOwnPtr<We
bCryptoAlgorithmParams>); |
113 #endif | 126 #endif |
114 | 127 |
115 BLINK_PLATFORM_EXPORT static WebCryptoAlgorithm createNull(); | 128 BLINK_PLATFORM_EXPORT static WebCryptoAlgorithm createNull(); |
116 BLINK_PLATFORM_EXPORT static WebCryptoAlgorithm adoptParamsAndCreate(WebCryp
toAlgorithmId, WebCryptoAlgorithmParams*); | 129 BLINK_PLATFORM_EXPORT static WebCryptoAlgorithm adoptParamsAndCreate(WebCryp
toAlgorithmId, WebCryptoAlgorithmParams*); |
117 | 130 |
| 131 // Returns a WebCryptoAlgorithmInfo for the algorithm with the given ID. If |
| 132 // the ID is invalid, return 0. The caller can assume the pointer will be |
| 133 // valid for the program's entire runtime. |
| 134 BLINK_PLATFORM_EXPORT static const WebCryptoAlgorithmInfo* lookupAlgorithmIn
fo(WebCryptoAlgorithmId); |
| 135 |
| 136 // Returns the canonical (case-sensitive) name for the algorithm with the |
| 137 // given ID as a null-terminated C-string literal. Caller can assume the |
| 138 // pointer will be valid for the program's entire runtime. |
| 139 BLINK_PLATFORM_EXPORT static const char* idToName(WebCryptoAlgorithmId); |
| 140 |
118 ~WebCryptoAlgorithm() { reset(); } | 141 ~WebCryptoAlgorithm() { reset(); } |
119 | 142 |
120 WebCryptoAlgorithm(const WebCryptoAlgorithm& other) { assign(other); } | 143 WebCryptoAlgorithm(const WebCryptoAlgorithm& other) { assign(other); } |
121 WebCryptoAlgorithm& operator=(const WebCryptoAlgorithm& other) | 144 WebCryptoAlgorithm& operator=(const WebCryptoAlgorithm& other) |
122 { | 145 { |
123 assign(other); | 146 assign(other); |
124 return *this; | 147 return *this; |
125 } | 148 } |
126 | 149 |
127 BLINK_PLATFORM_EXPORT bool isNull() const; | 150 BLINK_PLATFORM_EXPORT bool isNull() const; |
(...skipping 20 matching lines...) Expand all Loading... |
148 private: | 171 private: |
149 BLINK_PLATFORM_EXPORT void assign(const WebCryptoAlgorithm& other); | 172 BLINK_PLATFORM_EXPORT void assign(const WebCryptoAlgorithm& other); |
150 BLINK_PLATFORM_EXPORT void reset(); | 173 BLINK_PLATFORM_EXPORT void reset(); |
151 | 174 |
152 WebPrivatePtr<WebCryptoAlgorithmPrivate> m_private; | 175 WebPrivatePtr<WebCryptoAlgorithmPrivate> m_private; |
153 }; | 176 }; |
154 | 177 |
155 } // namespace blink | 178 } // namespace blink |
156 | 179 |
157 #endif | 180 #endif |
OLD | NEW |