OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "crypto/ec_signature_creator.h" | 5 #include "crypto/ec_signature_creator.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 std::string data("Hello, World!"); | 47 std::string data("Hello, World!"); |
48 std::vector<uint8> signature; | 48 std::vector<uint8> signature; |
49 ASSERT_TRUE(signer->Sign(reinterpret_cast<const uint8*>(data.c_str()), | 49 ASSERT_TRUE(signer->Sign(reinterpret_cast<const uint8*>(data.c_str()), |
50 data.size(), | 50 data.size(), |
51 &signature)); | 51 &signature)); |
52 | 52 |
53 std::vector<uint8> public_key_info; | 53 std::vector<uint8> public_key_info; |
54 ASSERT_TRUE(key_original->ExportPublicKey(&public_key_info)); | 54 ASSERT_TRUE(key_original->ExportPublicKey(&public_key_info)); |
55 | 55 |
56 // This is the algorithm ID for SHA-1 with EC encryption. | 56 // This is the algorithm ID for SHA-256 with EC encryption. |
57 const uint8 kECDSAWithSHA1AlgorithmID[] = { | 57 const uint8 kECDSAWithSHA256AlgorithmID[] = { |
58 0x30, 0x0b, | 58 0x30, 0x0c, |
59 0x06, 0x07, | 59 0x06, 0x08, |
60 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x01, | 60 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, |
61 0x05, 0x00 | 61 0x05, 0x00 |
62 }; | 62 }; |
63 crypto::SignatureVerifier verifier; | 63 crypto::SignatureVerifier verifier; |
64 ASSERT_TRUE(verifier.VerifyInit( | 64 ASSERT_TRUE(verifier.VerifyInit( |
65 kECDSAWithSHA1AlgorithmID, sizeof(kECDSAWithSHA1AlgorithmID), | 65 kECDSAWithSHA256AlgorithmID, sizeof(kECDSAWithSHA256AlgorithmID), |
66 &signature.front(), signature.size(), | 66 signature.data(), signature.size(), |
67 &public_key_info.front(), public_key_info.size())); | 67 &public_key_info.front(), public_key_info.size())); |
68 | 68 |
69 verifier.VerifyUpdate(reinterpret_cast<const uint8*>(data.c_str()), | 69 verifier.VerifyUpdate(reinterpret_cast<const uint8*>(data.c_str()), |
70 data.size()); | 70 data.size()); |
71 ASSERT_TRUE(verifier.VerifyFinal()); | 71 ASSERT_TRUE(verifier.VerifyFinal()); |
72 } | 72 } |
73 #endif // !defined(USE_OPENSSL) | 73 #endif // !defined(USE_OPENSSL) |
OLD | NEW |