Chromium Code Reviews| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 // Blink thread. | 165 // Blink thread. |
| 166 // | 166 // |
| 167 // * WebCryptoKey and WebCryptoAlgorithm ARE threadsafe. They can be | 167 // * WebCryptoKey and WebCryptoAlgorithm ARE threadsafe. They can be |
| 168 // safely copied between threads and accessed. Copying is cheap because | 168 // safely copied between threads and accessed. Copying is cheap because |
| 169 // they are internally reference counted. | 169 // they are internally reference counted. |
| 170 // | 170 // |
| 171 // ----------------------- | 171 // ----------------------- |
| 172 // Inputs | 172 // Inputs |
| 173 // ----------------------- | 173 // ----------------------- |
| 174 // | 174 // |
| 175 // * Data buffers are passed as (basePointer, byteLength) pairs. | 175 // * Data buffers are transfered as WebVectors. Implementations are free |
| 176 // These buffers are only valid during the call itself. Asynchronous | 176 // to re-use or transfer their storage. |
| 177 // implementations wishing to access it after the function returns | |
| 178 // should make a copy. | |
| 179 // | 177 // |
| 180 // * All WebCryptoKeys are guaranteeed to be !isNull(). | 178 // * All WebCryptoKeys are guaranteeed to be !isNull(). |
| 181 // | 179 // |
| 182 // * All WebCryptoAlgorithms are guaranteed to be !isNull() | 180 // * All WebCryptoAlgorithms are guaranteed to be !isNull() |
| 183 // | 181 // |
| 184 // * Look to the Web Crypto spec for an explanation of the parameter. The | 182 // * Look to the Web Crypto spec for an explanation of the parameter. The |
| 185 // method names here have a 1:1 correspondence with those of | 183 // method names here have a 1:1 correspondence with those of |
| 186 // crypto.subtle, with the exception of "verify" which is here called | 184 // crypto.subtle, with the exception of "verify" which is here called |
| 187 // "verifySignature". | 185 // "verifySignature". |
| 188 // | 186 // |
| 189 // ----------------------- | 187 // ----------------------- |
| 190 // Guarantees on input validity | 188 // Guarantees on input validity |
| 191 // ----------------------- | 189 // ----------------------- |
| 192 // | 190 // |
| 193 // Implementations MUST carefully sanitize algorithm inputs before using | 191 // Implementations MUST carefully sanitize algorithm inputs before using |
| 194 // them, as they come directly from the user. Few checks have been done on | 192 // them, as they come directly from the user. Few checks have been done on |
| 195 // algorithm parameters prior to passing to the embedder. | 193 // algorithm parameters prior to passing to the embedder. |
| 196 // | 194 // |
| 197 // Only the following checks can be assumed as having already passed: | 195 // Only the following checks can be assumed as having already passed: |
| 198 // | 196 // |
| 199 // * The key is extractable when calling into exportKey/wrapKey. | 197 // * The key is extractable when calling into exportKey/wrapKey. |
| 200 // * The key usages permit the operation being requested. | 198 // * The key usages permit the operation being requested. |
| 201 // * The key's algorithm matches that of the requested operation. | 199 // * The key's algorithm matches that of the requested operation. |
| 202 // | 200 // |
| 203 virtual void encrypt(const WebCryptoAlgorithm&, const WebCryptoKey&, const u nsigned char* data, unsigned dataSize, WebCryptoResult result) { result.complete WithError(WebCryptoErrorTypeNotSupported, ""); } | 201 virtual void encrypt(const WebCryptoAlgorithm&, const WebCryptoKey&, WebVect or<unsigned char> data, WebCryptoResult result) { result.completeWithError(WebCr yptoErrorTypeNotSupported, ""); } |
|
jochen (gone - plz use gerrit)
2016/07/19 12:27:40
why not WebVector<unsigned char>&
eroman
2016/07/19 16:17:41
My preference for pass-by-value is:
* Makes it c
| |
| 204 virtual void decrypt(const WebCryptoAlgorithm&, const WebCryptoKey&, const u nsigned char* data, unsigned dataSize, WebCryptoResult result) { result.complete WithError(WebCryptoErrorTypeNotSupported, ""); } | 202 virtual void decrypt(const WebCryptoAlgorithm&, const WebCryptoKey&, WebVect or<unsigned char> data, WebCryptoResult result) { result.completeWithError(WebCr yptoErrorTypeNotSupported, ""); } |
| 205 virtual void sign(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsi gned char* data, unsigned dataSize, WebCryptoResult result) { result.completeWit hError(WebCryptoErrorTypeNotSupported, ""); } | 203 virtual void sign(const WebCryptoAlgorithm&, const WebCryptoKey&, WebVector< unsigned char> data, WebCryptoResult result) { result.completeWithError(WebCrypt oErrorTypeNotSupported, ""); } |
| 206 virtual void verifySignature(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsigned char* signature, unsigned signatureSize, const unsigned char* da ta, unsigned dataSize, WebCryptoResult result) { result.completeWithError(WebCry ptoErrorTypeNotSupported, ""); } | 204 virtual void verifySignature(const WebCryptoAlgorithm&, const WebCryptoKey&, WebVector<unsigned char> signature, WebVector<unsigned char> data, WebCryptoRes ult result) { result.completeWithError(WebCryptoErrorTypeNotSupported, ""); } |
| 207 virtual void digest(const WebCryptoAlgorithm&, const unsigned char* data, un signed dataSize, WebCryptoResult result) { result.completeWithError(WebCryptoErr orTypeNotSupported, ""); } | 205 virtual void digest(const WebCryptoAlgorithm&, WebVector<unsigned char> data , WebCryptoResult result) { result.completeWithError(WebCryptoErrorTypeNotSuppor ted, ""); } |
| 208 virtual void generateKey(const WebCryptoAlgorithm&, bool extractable, WebCry ptoKeyUsageMask, WebCryptoResult result) { result.completeWithError(WebCryptoErr orTypeNotSupported, ""); } | 206 virtual void generateKey(const WebCryptoAlgorithm&, bool extractable, WebCry ptoKeyUsageMask, WebCryptoResult result) { result.completeWithError(WebCryptoErr orTypeNotSupported, ""); } |
| 209 virtual void importKey(WebCryptoKeyFormat, const unsigned char* keyData, uns igned keyDataSize, const WebCryptoAlgorithm&, bool extractable, WebCryptoKeyUsag eMask, WebCryptoResult result) { result.completeWithError(WebCryptoErrorTypeNotS upported, ""); } | 207 virtual void importKey(WebCryptoKeyFormat, WebVector<unsigned char> keyData, const WebCryptoAlgorithm&, bool extractable, WebCryptoKeyUsageMask, WebCryptoRe sult result) { result.completeWithError(WebCryptoErrorTypeNotSupported, ""); } |
| 210 virtual void exportKey(WebCryptoKeyFormat, const WebCryptoKey&, WebCryptoRes ult result) { result.completeWithError(WebCryptoErrorTypeNotSupported, ""); } | 208 virtual void exportKey(WebCryptoKeyFormat, const WebCryptoKey&, WebCryptoRes ult result) { result.completeWithError(WebCryptoErrorTypeNotSupported, ""); } |
| 211 virtual void wrapKey(WebCryptoKeyFormat, const WebCryptoKey& key, const WebC ryptoKey& wrappingKey, const WebCryptoAlgorithm&, WebCryptoResult result) { resu lt.completeWithError(WebCryptoErrorTypeNotSupported, ""); } | 209 virtual void wrapKey(WebCryptoKeyFormat, const WebCryptoKey& key, const WebC ryptoKey& wrappingKey, const WebCryptoAlgorithm&, WebCryptoResult result) { resu lt.completeWithError(WebCryptoErrorTypeNotSupported, ""); } |
| 212 virtual void unwrapKey(WebCryptoKeyFormat, const unsigned char* wrappedKey, unsigned wrappedKeySize, const WebCryptoKey&, const WebCryptoAlgorithm& unwrapAl gorithm, const WebCryptoAlgorithm& unwrappedKeyAlgorithm, bool extractable, WebC ryptoKeyUsageMask, WebCryptoResult result) { result.completeWithError(WebCryptoE rrorTypeNotSupported, ""); } | 210 virtual void unwrapKey(WebCryptoKeyFormat, WebVector<unsigned char> wrappedK ey, const WebCryptoKey&, const WebCryptoAlgorithm& unwrapAlgorithm, const WebCry ptoAlgorithm& unwrappedKeyAlgorithm, bool extractable, WebCryptoKeyUsageMask, We bCryptoResult result) { result.completeWithError(WebCryptoErrorTypeNotSupported, ""); } |
| 213 virtual void deriveBits(const WebCryptoAlgorithm&, const WebCryptoKey&, unsi gned length, WebCryptoResult result) { result.completeWithError(WebCryptoErrorTy peNotSupported, ""); } | 211 virtual void deriveBits(const WebCryptoAlgorithm&, const WebCryptoKey&, unsi gned length, WebCryptoResult result) { result.completeWithError(WebCryptoErrorTy peNotSupported, ""); } |
| 214 virtual void deriveKey(const WebCryptoAlgorithm& algorithm, const WebCryptoK ey& baseKey, const WebCryptoAlgorithm& importAlgorithm, const WebCryptoAlgorithm & keyLengthAlgorithm, bool extractable, WebCryptoKeyUsageMask, WebCryptoResult r esult) { result.completeWithError(WebCryptoErrorTypeNotSupported, ""); } | 212 virtual void deriveKey(const WebCryptoAlgorithm& algorithm, const WebCryptoK ey& baseKey, const WebCryptoAlgorithm& importAlgorithm, const WebCryptoAlgorithm & keyLengthAlgorithm, bool extractable, WebCryptoKeyUsageMask, WebCryptoResult r esult) { result.completeWithError(WebCryptoErrorTypeNotSupported, ""); } |
| 215 | 213 |
| 216 // This is the exception to the "Completing the request" guarantees | 214 // This is the exception to the "Completing the request" guarantees |
| 217 // outlined above. This is useful for Blink internal crypto and is not part | 215 // outlined above. This is useful for Blink internal crypto and is not part |
| 218 // of the WebCrypto standard. createDigestor must provide the result via | 216 // of the WebCrypto standard. createDigestor must provide the result via |
| 219 // the WebCryptoDigestor object synchronously. This will never return null. | 217 // the WebCryptoDigestor object synchronously. This will never return null. |
| 220 virtual std::unique_ptr<WebCryptoDigestor> createDigestor(WebCryptoAlgorithm Id algorithmId) { return nullptr; } | 218 virtual std::unique_ptr<WebCryptoDigestor> createDigestor(WebCryptoAlgorithm Id algorithmId) { return nullptr; } |
| 221 | 219 |
| 222 // ----------------------- | 220 // ----------------------- |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 // Returns true on success. | 265 // Returns true on success. |
| 268 virtual bool serializeKeyForClone(const WebCryptoKey&, WebVector<unsigned ch ar>&) { return false; } | 266 virtual bool serializeKeyForClone(const WebCryptoKey&, WebVector<unsigned ch ar>&) { return false; } |
| 269 | 267 |
| 270 protected: | 268 protected: |
| 271 virtual ~WebCrypto() { } | 269 virtual ~WebCrypto() { } |
| 272 }; | 270 }; |
| 273 | 271 |
| 274 } // namespace blink | 272 } // namespace blink |
| 275 | 273 |
| 276 #endif // WebCrypto_h | 274 #endif // WebCrypto_h |
| OLD | NEW |