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

Side by Side Diff: crypto/p224_unittest.cc

Issue 10822019: crypto: special case ∞+a, a+∞ and a+a in p224. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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
« crypto/p224.cc ('K') | « crypto/p224.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 reinterpret_cast<const char *>(kNISTTestVectors[10].affine), 56))); 799 reinterpret_cast<const char *>(kNISTTestVectors[10].affine), 56)));
800 ASSERT_TRUE(b.SetFromString(base::StringPiece( 800 ASSERT_TRUE(b.SetFromString(base::StringPiece(
801 reinterpret_cast<const char *>(kNISTTestVectors[11].affine), 56))); 801 reinterpret_cast<const char *>(kNISTTestVectors[11].affine), 56)));
802 802
803 p224::Negate(b, &minus_b); 803 p224::Negate(b, &minus_b);
804 p224::Add(a, b, &sum); 804 p224::Add(a, b, &sum);
805 EXPECT_TRUE(memcmp(&sum, &a, sizeof(sum) != 0)); 805 EXPECT_TRUE(memcmp(&sum, &a, sizeof(sum) != 0));
806 p224::Add(minus_b, sum, &a_again); 806 p224::Add(minus_b, sum, &a_again);
807 EXPECT_TRUE(a_again.ToString() == a.ToString()); 807 EXPECT_TRUE(a_again.ToString() == a.ToString());
808 } 808 }
809
810 TEST(P224, Infinity) {
811 char zeros[56];
812 memset(zeros, 0, sizeof(zeros));
813
814 // Test that x^0 = ∞.
815 Point a;
816 p224::ScalarBaseMult(reinterpret_cast<const uint8_t*>(zeros), &a);
817 EXPECT_TRUE(memcmp(zeros, a.ToString().data(), sizeof(zeros)) == 0);
818
819 // We shouldn't allow ∞ to be imported.
820 EXPECT_FALSE(a.SetFromString(std::string(zeros, sizeof(zeros))));
821 }
OLDNEW
« crypto/p224.cc ('K') | « crypto/p224.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698