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

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

Issue 23537027: WebCrypto: [refactor] Use "unsigned" rather than "size_t" for buffer sizes. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add an ifdef to coordinate with chromium side Created 7 years, 3 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/testing/runner/MockWebCrypto.cpp ('k') | public/platform/WebCryptoAlgorithmParams.h » ('j') | 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 19 matching lines...) Expand all
30 30
31 #ifndef WebCrypto_h 31 #ifndef WebCrypto_h
32 #define WebCrypto_h 32 #define WebCrypto_h
33 33
34 #include "WebCommon.h" 34 #include "WebCommon.h"
35 #include "WebCryptoKey.h" 35 #include "WebCryptoKey.h"
36 #include "WebPrivatePtr.h" 36 #include "WebPrivatePtr.h"
37 37
38 namespace WebCore { class CryptoResult; } 38 namespace WebCore { class CryptoResult; }
39 39
40 // FIXME: delete once chromium side has been updated.
41 #define WEBCRYPTO_DIGEST_LENGTH_IS_UINT
42
40 #if WEBKIT_IMPLEMENTATION 43 #if WEBKIT_IMPLEMENTATION
41 namespace WTF { template <typename T> class PassRefPtr; } 44 namespace WTF { template <typename T> class PassRefPtr; }
42 #endif 45 #endif
43 46
44 namespace WebKit { 47 namespace WebKit {
45 48
46 class WebArrayBuffer; 49 class WebArrayBuffer;
47 50
48 class WebCryptoResult { 51 class WebCryptoResult {
49 public: 52 public:
50 WebCryptoResult(const WebCryptoResult& o) 53 WebCryptoResult(const WebCryptoResult& o)
51 { 54 {
52 assign(o); 55 assign(o);
53 } 56 }
54 57
55 ~WebCryptoResult() 58 ~WebCryptoResult()
56 { 59 {
57 reset(); 60 reset();
58 } 61 }
59 62
60 WebCryptoResult& operator=(const WebCryptoResult& o) 63 WebCryptoResult& operator=(const WebCryptoResult& o)
61 { 64 {
62 assign(o); 65 assign(o);
63 return *this; 66 return *this;
64 } 67 }
65 68
66 WEBKIT_EXPORT void completeWithError(); 69 WEBKIT_EXPORT void completeWithError();
67 WEBKIT_EXPORT void completeWithBuffer(const WebArrayBuffer&); 70 WEBKIT_EXPORT void completeWithBuffer(const WebArrayBuffer&);
68 WEBKIT_EXPORT void completeWithBuffer(const void*, size_t); 71 WEBKIT_EXPORT void completeWithBuffer(const void*, unsigned);
69 WEBKIT_EXPORT void completeWithBoolean(bool); 72 WEBKIT_EXPORT void completeWithBoolean(bool);
70 WEBKIT_EXPORT void completeWithKey(const WebCryptoKey&); 73 WEBKIT_EXPORT void completeWithKey(const WebCryptoKey&);
71 WEBKIT_EXPORT void completeWithKeyPair(const WebCryptoKey& publicKey, const WebCryptoKey& privateKey); 74 WEBKIT_EXPORT void completeWithKeyPair(const WebCryptoKey& publicKey, const WebCryptoKey& privateKey);
72 75
73 #if WEBKIT_IMPLEMENTATION 76 #if WEBKIT_IMPLEMENTATION
74 explicit WebCryptoResult(const WTF::PassRefPtr<WebCore::CryptoResult>&); 77 explicit WebCryptoResult(const WTF::PassRefPtr<WebCore::CryptoResult>&);
75 #endif 78 #endif
76 79
77 private: 80 private:
78 WEBKIT_EXPORT void reset(); 81 WEBKIT_EXPORT void reset();
79 WEBKIT_EXPORT void assign(const WebCryptoResult&); 82 WEBKIT_EXPORT void assign(const WebCryptoResult&);
80 83
81 WebPrivatePtr<WebCore::CryptoResult> m_impl; 84 WebPrivatePtr<WebCore::CryptoResult> m_impl;
82 }; 85 };
83 86
84 class WebCrypto { 87 class WebCrypto {
85 public: 88 public:
86 // Starts a one-shot cryptographic operation which can complete either 89 // Starts a one-shot cryptographic operation which can complete either
87 // synchronously, or asynchronously. 90 // synchronously, or asynchronously.
88 // 91 //
89 // Let the WebCryptoResult be called "result". 92 // Let the WebCryptoResult be called "result".
90 // 93 //
91 // The result should be set exactly once, from the same thread which 94 // The result should be set exactly once, from the same thread which
92 // initiated the operation. 95 // initiated the operation.
93 virtual void encrypt(const WebCryptoAlgorithm&, const WebCryptoKey&, const u nsigned char* data, size_t data_size, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACH ED(); } 96 virtual void encrypt(const WebCryptoAlgorithm&, const WebCryptoKey&, const u nsigned char* data, unsigned dataSize, WebCryptoResult) { WEBKIT_ASSERT_NOT_REAC HED(); }
94 virtual void decrypt(const WebCryptoAlgorithm&, const WebCryptoKey&, const u nsigned char* data, size_t data_size, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACH ED(); } 97 virtual void decrypt(const WebCryptoAlgorithm&, const WebCryptoKey&, const u nsigned char* data, unsigned dataSize, WebCryptoResult) { WEBKIT_ASSERT_NOT_REAC HED(); }
95 virtual void sign(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsi gned char* data, size_t data_size, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED( ); } 98 virtual void sign(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsi gned char* data, unsigned dataSize, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED (); }
96 virtual void verifySignature(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsigned char* signature, size_t signature_size, const unsigned char* dat a, size_t data_size, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED(); } 99 virtual void verifySignature(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsigned char* signature, unsigned signatureSize, const unsigned char* da ta, unsigned dataSize, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED(); }
97 virtual void digest(const WebCryptoAlgorithm&, const unsigned char* data, si ze_t data_size, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED(); } 100 virtual void digest(const WebCryptoAlgorithm&, const unsigned char* data, un signed dataSize, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED(); }
98 virtual void generateKey(const WebCryptoAlgorithm&, bool extractable, WebCry ptoKeyUsageMask, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED(); } 101 virtual void generateKey(const WebCryptoAlgorithm&, bool extractable, WebCry ptoKeyUsageMask, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED(); }
99 virtual void importKey(WebCryptoKeyFormat, const unsigned char* keyData, siz e_t keyDataSize, const WebCryptoAlgorithm&, bool extractable, WebCryptoKeyUsageM ask, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED(); } 102 virtual void importKey(WebCryptoKeyFormat, const unsigned char* keyData, uns igned keyDataSize, const WebCryptoAlgorithm&, bool extractable, WebCryptoKeyUsag eMask, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED(); }
100 virtual void exportKey(WebCryptoKeyFormat, const WebCryptoKey&, WebCryptoRes ult) { WEBKIT_ASSERT_NOT_REACHED(); } 103 virtual void exportKey(WebCryptoKeyFormat, const WebCryptoKey&, WebCryptoRes ult) { WEBKIT_ASSERT_NOT_REACHED(); }
101 104
102 protected: 105 protected:
103 virtual ~WebCrypto() { } 106 virtual ~WebCrypto() { }
104 }; 107 };
105 108
106 } // namespace WebKit 109 } // namespace WebKit
107 110
108 #endif 111 #endif
OLDNEW
« no previous file with comments | « Source/testing/runner/MockWebCrypto.cpp ('k') | public/platform/WebCryptoAlgorithmParams.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698