| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 WebCryptoAlgorithmIdHmac, | 60 WebCryptoAlgorithmIdHmac, |
| 61 WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, | 61 WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, |
| 62 WebCryptoAlgorithmIdSha1, | 62 WebCryptoAlgorithmIdSha1, |
| 63 WebCryptoAlgorithmIdSha256, | 63 WebCryptoAlgorithmIdSha256, |
| 64 WebCryptoAlgorithmIdSha384, | 64 WebCryptoAlgorithmIdSha384, |
| 65 WebCryptoAlgorithmIdSha512, | 65 WebCryptoAlgorithmIdSha512, |
| 66 WebCryptoAlgorithmIdAesGcm, | 66 WebCryptoAlgorithmIdAesGcm, |
| 67 WebCryptoAlgorithmIdRsaOaep, | 67 WebCryptoAlgorithmIdRsaOaep, |
| 68 WebCryptoAlgorithmIdAesCtr, | 68 WebCryptoAlgorithmIdAesCtr, |
| 69 WebCryptoAlgorithmIdAesKw, | 69 WebCryptoAlgorithmIdAesKw, |
| 70 WebCryptoAlgorithmIdRsaPss, |
| 70 #if INSIDE_BLINK | 71 #if INSIDE_BLINK |
| 71 WebCryptoAlgorithmIdLast = WebCryptoAlgorithmIdAesKw, | 72 WebCryptoAlgorithmIdLast = WebCryptoAlgorithmIdRsaPss, |
| 72 #endif | 73 #endif |
| 73 }; | 74 }; |
| 74 | 75 |
| 75 enum WebCryptoAlgorithmParamsType { | 76 enum WebCryptoAlgorithmParamsType { |
| 76 WebCryptoAlgorithmParamsTypeNone, | 77 WebCryptoAlgorithmParamsTypeNone, |
| 77 WebCryptoAlgorithmParamsTypeAesCbcParams, | 78 WebCryptoAlgorithmParamsTypeAesCbcParams, |
| 78 WebCryptoAlgorithmParamsTypeAesKeyGenParams, | 79 WebCryptoAlgorithmParamsTypeAesKeyGenParams, |
| 79 WebCryptoAlgorithmParamsTypeHmacImportParams, | 80 WebCryptoAlgorithmParamsTypeHmacImportParams, |
| 80 WebCryptoAlgorithmParamsTypeHmacKeyGenParams, | 81 WebCryptoAlgorithmParamsTypeHmacKeyGenParams, |
| 81 WebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams, | 82 WebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams, |
| 82 WebCryptoAlgorithmParamsTypeRsaHashedImportParams, | 83 WebCryptoAlgorithmParamsTypeRsaHashedImportParams, |
| 83 WebCryptoAlgorithmParamsTypeAesGcmParams, | 84 WebCryptoAlgorithmParamsTypeAesGcmParams, |
| 84 WebCryptoAlgorithmParamsTypeRsaOaepParams, | 85 WebCryptoAlgorithmParamsTypeRsaOaepParams, |
| 85 WebCryptoAlgorithmParamsTypeAesCtrParams, | 86 WebCryptoAlgorithmParamsTypeAesCtrParams, |
| 87 WebCryptoAlgorithmParamsTypeRsaPssParams, |
| 86 }; | 88 }; |
| 87 | 89 |
| 88 struct WebCryptoAlgorithmInfo { | 90 struct WebCryptoAlgorithmInfo { |
| 89 typedef char ParamsTypeOrUndefined; | 91 typedef char ParamsTypeOrUndefined; |
| 90 static const ParamsTypeOrUndefined Undefined = -1; | 92 static const ParamsTypeOrUndefined Undefined = -1; |
| 91 | 93 |
| 92 // The canonical (case-sensitive) name for the algorithm as a | 94 // The canonical (case-sensitive) name for the algorithm as a |
| 93 // null-terminated C-string literal. | 95 // null-terminated C-string literal. |
| 94 const char* name; | 96 const char* name; |
| 95 | 97 |
| 96 // A map from the operation to the expected parameter type of the algorithm. | 98 // A map from the operation to the expected parameter type of the algorithm. |
| 97 // If an operation is not applicable for the algorithm, set to Undefined. | 99 // If an operation is not applicable for the algorithm, set to Undefined. |
| 98 const ParamsTypeOrUndefined operationToParamsType[WebCryptoOperationLast + 1
]; | 100 const ParamsTypeOrUndefined operationToParamsType[WebCryptoOperationLast + 1
]; |
| 99 }; | 101 }; |
| 100 | 102 |
| 101 | 103 |
| 102 class WebCryptoAesCbcParams; | 104 class WebCryptoAesCbcParams; |
| 103 class WebCryptoAesKeyGenParams; | 105 class WebCryptoAesKeyGenParams; |
| 104 class WebCryptoHmacImportParams; | 106 class WebCryptoHmacImportParams; |
| 105 class WebCryptoHmacKeyGenParams; | 107 class WebCryptoHmacKeyGenParams; |
| 106 class WebCryptoAesGcmParams; | 108 class WebCryptoAesGcmParams; |
| 107 class WebCryptoRsaOaepParams; | 109 class WebCryptoRsaOaepParams; |
| 108 class WebCryptoAesCtrParams; | 110 class WebCryptoAesCtrParams; |
| 109 class WebCryptoRsaHashedKeyGenParams; | 111 class WebCryptoRsaHashedKeyGenParams; |
| 110 class WebCryptoRsaHashedImportParams; | 112 class WebCryptoRsaHashedImportParams; |
| 113 class WebCryptoRsaPssParams; |
| 111 | 114 |
| 112 class WebCryptoAlgorithmParams; | 115 class WebCryptoAlgorithmParams; |
| 113 class WebCryptoAlgorithmPrivate; | 116 class WebCryptoAlgorithmPrivate; |
| 114 | 117 |
| 115 // The WebCryptoAlgorithm represents a normalized algorithm and its parameters. | 118 // The WebCryptoAlgorithm represents a normalized algorithm and its parameters. |
| 116 // * Immutable | 119 // * Immutable |
| 117 // * Threadsafe | 120 // * Threadsafe |
| 118 // * Copiable (cheaply) | 121 // * Copiable (cheaply) |
| 119 // | 122 // |
| 120 // If WebCryptoAlgorithm "isNull()" then it is invalid to call any of the other | 123 // If WebCryptoAlgorithm "isNull()" then it is invalid to call any of the other |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 // type of parameters. Retrieving an invalid parameter will return 0. | 156 // type of parameters. Retrieving an invalid parameter will return 0. |
| 154 BLINK_PLATFORM_EXPORT const WebCryptoAesCbcParams* aesCbcParams() const; | 157 BLINK_PLATFORM_EXPORT const WebCryptoAesCbcParams* aesCbcParams() const; |
| 155 BLINK_PLATFORM_EXPORT const WebCryptoAesKeyGenParams* aesKeyGenParams() cons
t; | 158 BLINK_PLATFORM_EXPORT const WebCryptoAesKeyGenParams* aesKeyGenParams() cons
t; |
| 156 BLINK_PLATFORM_EXPORT const WebCryptoHmacImportParams* hmacImportParams() co
nst; | 159 BLINK_PLATFORM_EXPORT const WebCryptoHmacImportParams* hmacImportParams() co
nst; |
| 157 BLINK_PLATFORM_EXPORT const WebCryptoHmacKeyGenParams* hmacKeyGenParams() co
nst; | 160 BLINK_PLATFORM_EXPORT const WebCryptoHmacKeyGenParams* hmacKeyGenParams() co
nst; |
| 158 BLINK_PLATFORM_EXPORT const WebCryptoAesGcmParams* aesGcmParams() const; | 161 BLINK_PLATFORM_EXPORT const WebCryptoAesGcmParams* aesGcmParams() const; |
| 159 BLINK_PLATFORM_EXPORT const WebCryptoRsaOaepParams* rsaOaepParams() const; | 162 BLINK_PLATFORM_EXPORT const WebCryptoRsaOaepParams* rsaOaepParams() const; |
| 160 BLINK_PLATFORM_EXPORT const WebCryptoAesCtrParams* aesCtrParams() const; | 163 BLINK_PLATFORM_EXPORT const WebCryptoAesCtrParams* aesCtrParams() const; |
| 161 BLINK_PLATFORM_EXPORT const WebCryptoRsaHashedImportParams* rsaHashedImportP
arams() const; | 164 BLINK_PLATFORM_EXPORT const WebCryptoRsaHashedImportParams* rsaHashedImportP
arams() const; |
| 162 BLINK_PLATFORM_EXPORT const WebCryptoRsaHashedKeyGenParams* rsaHashedKeyGenP
arams() const; | 165 BLINK_PLATFORM_EXPORT const WebCryptoRsaHashedKeyGenParams* rsaHashedKeyGenP
arams() const; |
| 166 BLINK_PLATFORM_EXPORT const WebCryptoRsaPssParams* rsaPssParams() const; |
| 163 | 167 |
| 164 // Returns true if the provided algorithm ID is for a hash (in other words,
SHA-*) | 168 // Returns true if the provided algorithm ID is for a hash (in other words,
SHA-*) |
| 165 BLINK_PLATFORM_EXPORT static bool isHash(WebCryptoAlgorithmId); | 169 BLINK_PLATFORM_EXPORT static bool isHash(WebCryptoAlgorithmId); |
| 166 | 170 |
| 167 private: | 171 private: |
| 168 BLINK_PLATFORM_EXPORT void assign(const WebCryptoAlgorithm& other); | 172 BLINK_PLATFORM_EXPORT void assign(const WebCryptoAlgorithm& other); |
| 169 BLINK_PLATFORM_EXPORT void reset(); | 173 BLINK_PLATFORM_EXPORT void reset(); |
| 170 | 174 |
| 171 WebPrivatePtr<WebCryptoAlgorithmPrivate> m_private; | 175 WebPrivatePtr<WebCryptoAlgorithmPrivate> m_private; |
| 172 }; | 176 }; |
| 173 | 177 |
| 174 } // namespace blink | 178 } // namespace blink |
| 175 | 179 |
| 176 #endif | 180 #endif |
| OLD | NEW |