Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Side by Side Diff: public/platform/WebCrypto.h

Issue 198513002: [webcrypto] Make the import algorithm a required parameter. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/modules/crypto/SubtleCrypto.idl ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // ----------------------- 140 // -----------------------
141 // 141 //
142 // * Data buffers are passed as (basePointer, byteLength) pairs. 142 // * Data buffers are passed as (basePointer, byteLength) pairs.
143 // These buffers are only valid during the call itself. Asynchronous 143 // These buffers are only valid during the call itself. Asynchronous
144 // implementations wishing to access it after the function returns 144 // implementations wishing to access it after the function returns
145 // should make a copy. 145 // should make a copy.
146 // 146 //
147 // * All WebCryptoKeys are guaranteeed to be !isNull(). 147 // * All WebCryptoKeys are guaranteeed to be !isNull().
148 // 148 //
149 // * All WebCryptoAlgorithms are guaranteed to be !isNull() 149 // * All WebCryptoAlgorithms are guaranteed to be !isNull()
150 // unless noted otherwise. Being "null" means that it was unspecified
151 // by the caller.
152 // 150 //
153 // * Look to the Web Crypto spec for an explanation of the parameter. The 151 // * Look to the Web Crypto spec for an explanation of the parameter. The
154 // method names here have a 1:1 correspondence with those of 152 // method names here have a 1:1 correspondence with those of
155 // crypto.subtle, with the exception of "verify" which is here called 153 // crypto.subtle, with the exception of "verify" which is here called
156 // "verifySignature". 154 // "verifySignature".
157 // 155 //
158 // ----------------------- 156 // -----------------------
159 // Guarantees on input validity 157 // Guarantees on input validity
160 // ----------------------- 158 // -----------------------
161 // 159 //
162 // Implementations MUST carefully sanitize algorithm inputs before using 160 // Implementations MUST carefully sanitize algorithm inputs before using
163 // them, as they come directly from the user. Few checks have been done on 161 // them, as they come directly from the user. Few checks have been done on
164 // algorithm parameters prior to passing to the embedder. 162 // algorithm parameters prior to passing to the embedder.
165 // 163 //
166 // Only the following checks can be assumed as having alread passed: 164 // Only the following checks can be assumed as having alread passed:
167 // 165 //
168 // * The key is extractable when calling into exportKey/wrapKey. 166 // * The key is extractable when calling into exportKey/wrapKey.
169 // * The key usages permit the operation being requested. 167 // * The key usages permit the operation being requested.
170 // * The key's algorithm matches that of the requested operation. 168 // * The key's algorithm matches that of the requested operation.
171 // 169 //
172 virtual void encrypt(const WebCryptoAlgorithm&, const WebCryptoKey&, const u nsigned char* data, unsigned dataSize, WebCryptoResult result) { result.complete WithError(); } 170 virtual void encrypt(const WebCryptoAlgorithm&, const WebCryptoKey&, const u nsigned char* data, unsigned dataSize, WebCryptoResult result) { result.complete WithError(); }
173 virtual void decrypt(const WebCryptoAlgorithm&, const WebCryptoKey&, const u nsigned char* data, unsigned dataSize, WebCryptoResult result) { result.complete WithError(); } 171 virtual void decrypt(const WebCryptoAlgorithm&, const WebCryptoKey&, const u nsigned char* data, unsigned dataSize, WebCryptoResult result) { result.complete WithError(); }
174 virtual void sign(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsi gned char* data, unsigned dataSize, WebCryptoResult result) { result.completeWit hError(); } 172 virtual void sign(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsi gned char* data, unsigned dataSize, WebCryptoResult result) { result.completeWit hError(); }
175 virtual void verifySignature(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsigned char* signature, unsigned signatureSize, const unsigned char* da ta, unsigned dataSize, WebCryptoResult result) { result.completeWithError(); } 173 virtual void verifySignature(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsigned char* signature, unsigned signatureSize, const unsigned char* da ta, unsigned dataSize, WebCryptoResult result) { result.completeWithError(); }
176 virtual void digest(const WebCryptoAlgorithm&, const unsigned char* data, un signed dataSize, WebCryptoResult result) { result.completeWithError(); } 174 virtual void digest(const WebCryptoAlgorithm&, const unsigned char* data, un signed dataSize, WebCryptoResult result) { result.completeWithError(); }
177 virtual void generateKey(const WebCryptoAlgorithm&, bool extractable, WebCry ptoKeyUsageMask, WebCryptoResult result) { result.completeWithError(); } 175 virtual void generateKey(const WebCryptoAlgorithm&, bool extractable, WebCry ptoKeyUsageMask, WebCryptoResult result) { result.completeWithError(); }
178 // It is possible for the WebCryptoAlgorithm to be "isNull()"
179 virtual void importKey(WebCryptoKeyFormat, const unsigned char* keyData, uns igned keyDataSize, const WebCryptoAlgorithm&, bool extractable, WebCryptoKeyUsag eMask, WebCryptoResult result) { result.completeWithError(); } 176 virtual void importKey(WebCryptoKeyFormat, const unsigned char* keyData, uns igned keyDataSize, const WebCryptoAlgorithm&, bool extractable, WebCryptoKeyUsag eMask, WebCryptoResult result) { result.completeWithError(); }
180 virtual void exportKey(WebCryptoKeyFormat, const WebCryptoKey&, WebCryptoRes ult result) { result.completeWithError(); } 177 virtual void exportKey(WebCryptoKeyFormat, const WebCryptoKey&, WebCryptoRes ult result) { result.completeWithError(); }
181 virtual void wrapKey(WebCryptoKeyFormat, const WebCryptoKey& key, const WebC ryptoKey& wrappingKey, const WebCryptoAlgorithm&, WebCryptoResult result) { resu lt.completeWithError(); } 178 virtual void wrapKey(WebCryptoKeyFormat, const WebCryptoKey& key, const WebC ryptoKey& wrappingKey, const WebCryptoAlgorithm&, WebCryptoResult result) { resu lt.completeWithError(); }
182 // It is possible that unwrappedKeyAlgorithm.isNull()
183 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(); } 179 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(); }
184 180
185 // This is the one exception to the "Completing the request" guarantees 181 // This is the one exception to the "Completing the request" guarantees
186 // outlined above. digestSynchronous must provide the result into result 182 // outlined above. digestSynchronous must provide the result into result
187 // synchronously. It must return |true| on successful calculation of the 183 // synchronously. It must return |true| on successful calculation of the
188 // digest and |false| otherwise. This is useful for Blink internal crypto 184 // digest and |false| otherwise. This is useful for Blink internal crypto
189 // and is not part of the WebCrypto standard. 185 // and is not part of the WebCrypto standard.
190 virtual bool digestSynchronous(const WebCryptoAlgorithmId algorithmId, const unsigned char* data, unsigned dataSize, WebArrayBuffer& result) { return false; } 186 virtual bool digestSynchronous(const WebCryptoAlgorithmId algorithmId, const unsigned char* data, unsigned dataSize, WebArrayBuffer& result) { return false; }
191 187
192 protected: 188 protected:
193 virtual ~WebCrypto() { } 189 virtual ~WebCrypto() { }
194 }; 190 };
195 191
196 } // namespace blink 192 } // namespace blink
197 193
198 #endif 194 #endif
OLDNEW
« no previous file with comments | « Source/modules/crypto/SubtleCrypto.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698