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

Side by Side Diff: Source/modules/crypto/SubtleCrypto.h

Issue 267133002: [webcrypto] Allow both ArrayBuffer and ArrayBufferView as inputs to crypto.subtle methods. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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
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 27 matching lines...) Expand all
38 #include "wtf/PassRefPtr.h" 38 #include "wtf/PassRefPtr.h"
39 #include "wtf/RefCounted.h" 39 #include "wtf/RefCounted.h"
40 40
41 namespace WebCore { 41 namespace WebCore {
42 42
43 class Dictionary; 43 class Dictionary;
44 class Key; 44 class Key;
45 45
46 class SubtleCrypto : public GarbageCollectedFinalized<SubtleCrypto>, public Scr iptWrappable { 46 class SubtleCrypto : public GarbageCollectedFinalized<SubtleCrypto>, public Scr iptWrappable {
47 public: 47 public:
48 // Adapter to implicitly convert an ArrayBuffer* or ArrayBufferView* to a
49 // common data type. This simplifies having to define a bunch of overloads
50 // for functions that take either parameter.
51 struct Bytes {
52 Bytes();
53 Bytes(ArrayBuffer*);
54 Bytes(ArrayBufferView*);
55
56 const unsigned char* bytes;
57 unsigned size;
58 bool isNull;
59
60 private:
61 void initNull();
62 };
abarth-chromium 2014/05/06 05:30:49 Can you move this class in WTF? It seems generall
eroman 2014/05/06 21:27:26 Done.
63
48 static SubtleCrypto* create() 64 static SubtleCrypto* create()
49 { 65 {
50 return new SubtleCrypto(); 66 return new SubtleCrypto();
51 } 67 }
52 68
53 ScriptPromise encrypt(const Dictionary&, Key*, ArrayBufferView* data); 69 ScriptPromise encrypt(const Dictionary&, Key*, const Bytes&);
54 ScriptPromise decrypt(const Dictionary&, Key*, ArrayBufferView* data); 70 ScriptPromise decrypt(const Dictionary&, Key*, const Bytes&);
55 ScriptPromise sign(const Dictionary&, Key*, ArrayBufferView* data); 71 ScriptPromise sign(const Dictionary&, Key*, const Bytes&);
56 // Note that this is not named "verify" because when compiling on Mac that e xpands to a macro and breaks. 72 // Note that this is not named "verify" because when compiling on Mac that e xpands to a macro and breaks.
57 ScriptPromise verifySignature(const Dictionary&, Key*, ArrayBufferView* sign ature, ArrayBufferView* data); 73 ScriptPromise verifySignature(const Dictionary&, Key*, const Bytes& signatur e, const Bytes& data);
58 ScriptPromise digest(const Dictionary&, ArrayBufferView* data); 74 ScriptPromise digest(const Dictionary&, const Bytes& data);
59 75
60 ScriptPromise generateKey(const Dictionary&, bool extractable, const Vector< String>& keyUsages); 76 ScriptPromise generateKey(const Dictionary&, bool extractable, const Vector< String>& keyUsages);
61 ScriptPromise importKey(const String&, ArrayBufferView*, const Dictionary&, bool extractable, const Vector<String>& keyUsages); 77 ScriptPromise importKey(const String&, const Bytes&, const Dictionary&, bool extractable, const Vector<String>& keyUsages);
62 ScriptPromise exportKey(const String&, Key*); 78 ScriptPromise exportKey(const String&, Key*);
63 79
64 ScriptPromise wrapKey(const String&, Key*, Key*, const Dictionary&); 80 ScriptPromise wrapKey(const String&, Key*, Key*, const Dictionary&);
65 ScriptPromise unwrapKey(const String&, ArrayBufferView*, Key*, const Diction ary&, const Dictionary&, bool, const Vector<String>&); 81 ScriptPromise unwrapKey(const String&, const Bytes&, Key*, const Dictionary& , const Dictionary&, bool, const Vector<String>&);
66 82
67 void trace(Visitor*) { } 83 void trace(Visitor*) { }
68 84
69 private: 85 private:
70 SubtleCrypto(); 86 SubtleCrypto();
71 }; 87 };
72 88
73 } // namespace WebCore 89 } // namespace WebCore
74 90
75 #endif 91 #endif
OLDNEW
« no previous file with comments | « LayoutTests/crypto/unwrapKey-badParameters-expected.txt ('k') | Source/modules/crypto/SubtleCrypto.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698