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 <string.h> | 5 #include <string.h> |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 | 7 |
8 #include "crypto/p224.h" | 8 #include "crypto/p224.h" |
9 | 9 |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 using namespace crypto; | 12 namespace crypto { |
| 13 |
13 using p224::Point; | 14 using p224::Point; |
14 | 15 |
15 // kBasePointExternal is the P224 base point in external representation. | 16 // kBasePointExternal is the P224 base point in external representation. |
16 static const uint8 kBasePointExternal[56] = { | 17 static const uint8 kBasePointExternal[56] = { |
17 0xb7, 0x0e, 0x0c, 0xbd, 0x6b, 0xb4, 0xbf, 0x7f, | 18 0xb7, 0x0e, 0x0c, 0xbd, 0x6b, 0xb4, 0xbf, 0x7f, |
18 0x32, 0x13, 0x90, 0xb9, 0x4a, 0x03, 0xc1, 0xd3, | 19 0x32, 0x13, 0x90, 0xb9, 0x4a, 0x03, 0xc1, 0xd3, |
19 0x56, 0xc2, 0x11, 0x22, 0x34, 0x32, 0x80, 0xd6, | 20 0x56, 0xc2, 0x11, 0x22, 0x34, 0x32, 0x80, 0xd6, |
20 0x11, 0x5c, 0x1d, 0x21, 0xbd, 0x37, 0x63, 0x88, | 21 0x11, 0x5c, 0x1d, 0x21, 0xbd, 0x37, 0x63, 0x88, |
21 0xb5, 0xf7, 0x23, 0xfb, 0x4c, 0x22, 0xdf, 0xe6, | 22 0xb5, 0xf7, 0x23, 0xfb, 0x4c, 0x22, 0xdf, 0xe6, |
22 0xcd, 0x43, 0x75, 0xa0, 0x5a, 0x07, 0x47, 0x64, | 23 0xcd, 0x43, 0x75, 0xa0, 0x5a, 0x07, 0x47, 0x64, |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 memset(zeros, 0, sizeof(zeros)); | 813 memset(zeros, 0, sizeof(zeros)); |
813 | 814 |
814 // Test that x^0 = ∞. | 815 // Test that x^0 = ∞. |
815 Point a; | 816 Point a; |
816 p224::ScalarBaseMult(reinterpret_cast<const uint8*>(zeros), &a); | 817 p224::ScalarBaseMult(reinterpret_cast<const uint8*>(zeros), &a); |
817 EXPECT_TRUE(memcmp(zeros, a.ToString().data(), sizeof(zeros)) == 0); | 818 EXPECT_TRUE(memcmp(zeros, a.ToString().data(), sizeof(zeros)) == 0); |
818 | 819 |
819 // We shouldn't allow ∞ to be imported. | 820 // We shouldn't allow ∞ to be imported. |
820 EXPECT_FALSE(a.SetFromString(std::string(zeros, sizeof(zeros)))); | 821 EXPECT_FALSE(a.SetFromString(std::string(zeros, sizeof(zeros)))); |
821 } | 822 } |
| 823 |
| 824 } // namespace crypto |
OLD | NEW |