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

Side by Side Diff: Source/modules/crypto/Key.cpp

Issue 18801015: WebCrypto: Update the key usage names to reflect recent changes to the spec. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 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/Key.h ('k') | Source/modules/crypto/Key.idl » ('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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 { 55 {
56 switch (usage) { 56 switch (usage) {
57 case WebKit::WebCryptoKeyUsageEncrypt: 57 case WebKit::WebCryptoKeyUsageEncrypt:
58 return "encrypt"; 58 return "encrypt";
59 case WebKit::WebCryptoKeyUsageDecrypt: 59 case WebKit::WebCryptoKeyUsageDecrypt:
60 return "decrypt"; 60 return "decrypt";
61 case WebKit::WebCryptoKeyUsageSign: 61 case WebKit::WebCryptoKeyUsageSign:
62 return "sign"; 62 return "sign";
63 case WebKit::WebCryptoKeyUsageVerify: 63 case WebKit::WebCryptoKeyUsageVerify:
64 return "verify"; 64 return "verify";
65 case WebKit::WebCryptoKeyUsageDerive: 65 case WebKit::WebCryptoKeyUsageDeriveKey:
66 return "derive"; 66 return "deriveKey";
67 case WebKit::WebCryptoKeyUsageWrap: 67 case WebKit::WebCryptoKeyUsageWrapKey:
68 return "wrap"; 68 return "wrapKey";
69 case WebKit::WebCryptoKeyUsageUnwrap: 69 case WebKit::WebCryptoKeyUsageUnwrapKey:
70 return "unwrap"; 70 return "unwrapKey";
71 case WebKit::EndOfWebCryptoKeyUsage: 71 case WebKit::EndOfWebCryptoKeyUsage:
72 break; 72 break;
73 } 73 }
74 ASSERT_NOT_REACHED(); 74 ASSERT_NOT_REACHED();
75 return 0; 75 return 0;
76 } 76 }
77 77
78 } // namespace 78 } // namespace
79 79
80 Key::Key(const WebKit::WebCryptoKey& key) 80 Key::Key(const WebKit::WebCryptoKey& key)
(...skipping 16 matching lines...) Expand all
97 { 97 {
98 if (!m_algorithm) 98 if (!m_algorithm)
99 m_algorithm = Algorithm::create(m_key.algorithm()); 99 m_algorithm = Algorithm::create(m_key.algorithm());
100 return m_algorithm.get(); 100 return m_algorithm.get();
101 } 101 }
102 102
103 // FIXME: This creates a new javascript array each time. What should happen 103 // FIXME: This creates a new javascript array each time. What should happen
104 // instead is return the same (immutable) array. (Javascript callers can 104 // instead is return the same (immutable) array. (Javascript callers can
105 // distinguish this by doing an == test on the arrays and seeing they are 105 // distinguish this by doing an == test on the arrays and seeing they are
106 // different). 106 // different).
107 Vector<String> Key::keyUsage() const 107 Vector<String> Key::usages() const
108 { 108 {
109 Vector<String> result; 109 Vector<String> result;
110 110
111 // The WebCryptoKeyUsage values are consecutive powers of 2. Test each one i n order. 111 // The WebCryptoKeyUsage values are consecutive powers of 2. Test each one i n order.
112 for (int i = 0; (1 << i) < WebKit::EndOfWebCryptoKeyUsage; ++i) { 112 for (int i = 0; (1 << i) < WebKit::EndOfWebCryptoKeyUsage; ++i) {
113 WebKit::WebCryptoKeyUsage usage = static_cast<WebKit::WebCryptoKeyUsage> (1 << i); 113 WebKit::WebCryptoKeyUsage usage = static_cast<WebKit::WebCryptoKeyUsage> (1 << i);
114 if (m_key.keyUsage() & usage) 114 if (m_key.usages() & usage)
115 result.append(ASCIILiteral(keyUsageToString(usage))); 115 result.append(ASCIILiteral(keyUsageToString(usage)));
116 } 116 }
117 return result; 117 return result;
118 } 118 }
119 119
120 } // namespace WebCore 120 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/crypto/Key.h ('k') | Source/modules/crypto/Key.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698