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

Side by Side Diff: Source/testing/runner/MockWebCrypto.cpp

Issue 23617006: WebCrypto: Add the KeyPair interface. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase onto master 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/modules/modules.gypi ('k') | public/platform/WebCrypto.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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } else if (input == std::string("\x00\x01\x02\x03\x04\x05", 6)) { 97 } else if (input == std::string("\x00\x01\x02\x03\x04\x05", 6)) {
98 const unsigned char resultBytes[] = {0x86, 0x84, 0x60, 0xd9, 0x8d, 0x09, 0xd8, 0xbb, 0xb9, 0x3d, 0x7b, 0x6c, 0xdd, 0x15, 0xcc, 0x7f, 0xbe, 0xc6, 0x76, 0 xb9}; 98 const unsigned char resultBytes[] = {0x86, 0x84, 0x60, 0xd9, 0x8d, 0x09, 0xd8, 0xbb, 0xb9, 0x3d, 0x7b, 0x6c, 0xdd, 0x15, 0xcc, 0x7f, 0xbe, 0xc6, 0x76, 0 xb9};
99 result.completeWithBuffer(resultBytes, sizeof(resultBytes)); 99 result.completeWithBuffer(resultBytes, sizeof(resultBytes));
100 } else { 100 } else {
101 result.completeWithError(); 101 result.completeWithError();
102 } 102 }
103 } 103 }
104 104
105 void MockWebCrypto::generateKey(const WebKit::WebCryptoAlgorithm& algorithm, boo l extractable, WebKit::WebCryptoKeyUsageMask usages, WebKit::WebCryptoResult res ult) 105 void MockWebCrypto::generateKey(const WebKit::WebCryptoAlgorithm& algorithm, boo l extractable, WebKit::WebCryptoKeyUsageMask usages, WebKit::WebCryptoResult res ult)
106 { 106 {
107 result.completeWithKey(WebKit::WebCryptoKey::create(0, WebKit::WebCryptoKeyT ypePrivate, extractable, algorithm, usages)); 107 if (algorithm.id() == WebKit::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5) {
108 result.completeWithKeyPair(WebKit::WebCryptoKey::create(0, WebKit::WebCr yptoKeyTypePublic, extractable, algorithm, usages), WebKit::WebCryptoKey::create (0, WebKit::WebCryptoKeyTypePrivate, extractable, algorithm, usages));
109 } else {
110 result.completeWithKey(WebKit::WebCryptoKey::create(0, WebKit::WebCrypto KeyTypePrivate, extractable, algorithm, usages));
111 }
108 } 112 }
109 113
110 void MockWebCrypto::importKey(WebKit::WebCryptoKeyFormat, const unsigned char* k eyData, size_t keyDataSize, const WebKit::WebCryptoAlgorithm& algorithm, bool ex tractable, WebKit::WebCryptoKeyUsageMask usages, WebKit::WebCryptoResult result) 114 void MockWebCrypto::importKey(WebKit::WebCryptoKeyFormat, const unsigned char* k eyData, size_t keyDataSize, const WebKit::WebCryptoAlgorithm& algorithm, bool ex tractable, WebKit::WebCryptoKeyUsageMask usages, WebKit::WebCryptoResult result)
111 { 115 {
112 std::string keyDataString(reinterpret_cast<const char*>(keyData), keyDataSiz e); 116 std::string keyDataString(reinterpret_cast<const char*>(keyData), keyDataSiz e);
113 117
114 if (keyDataString == "error") 118 if (keyDataString == "error")
115 return result.completeWithError(); 119 return result.completeWithError();
116 120
117 WebKit::WebCryptoKeyType type = WebKit::WebCryptoKeyTypePrivate; 121 WebKit::WebCryptoKeyType type = WebKit::WebCryptoKeyTypePrivate;
118 if (keyDataString == "public") 122 if (keyDataString == "public")
119 type = WebKit::WebCryptoKeyTypePublic; 123 type = WebKit::WebCryptoKeyTypePublic;
120 124
121 result.completeWithKey(WebKit::WebCryptoKey::create(0, type, extractable, al gorithm, usages)); 125 result.completeWithKey(WebKit::WebCryptoKey::create(0, type, extractable, al gorithm, usages));
122 } 126 }
123 127
124 } // namespace WebTestRunner 128 } // namespace WebTestRunner
OLDNEW
« no previous file with comments | « Source/modules/modules.gypi ('k') | public/platform/WebCrypto.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698