| OLD | NEW |
| 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 "crypto/signature_verifier.h" | 5 #include "crypto/signature_verifier.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 if (len < 128) { | 985 if (len < 128) { |
| 986 out->insert(out->begin(), static_cast<uint8_t>(len)); | 986 out->insert(out->begin(), static_cast<uint8_t>(len)); |
| 987 } else if (len < 256) { | 987 } else if (len < 256) { |
| 988 out->insert(out->begin(), static_cast<uint8_t>(len)); | 988 out->insert(out->begin(), static_cast<uint8_t>(len)); |
| 989 out->insert(out->begin(), 0x81); | 989 out->insert(out->begin(), 0x81); |
| 990 } else if (len < 0x10000) { | 990 } else if (len < 0x10000) { |
| 991 out->insert(out->begin(), static_cast<uint8_t>(len)); | 991 out->insert(out->begin(), static_cast<uint8_t>(len)); |
| 992 out->insert(out->begin(), static_cast<uint8_t>(len >> 8)); | 992 out->insert(out->begin(), static_cast<uint8_t>(len >> 8)); |
| 993 out->insert(out->begin(), 0x82); | 993 out->insert(out->begin(), 0x82); |
| 994 } else { | 994 } else { |
| 995 CHECK(false) << "ASN.1 length not handled: " << len; | 995 // ASN.1 length not handled. |
| 996 CHECK(false); |
| 996 } | 997 } |
| 997 } | 998 } |
| 998 | 999 |
| 999 static bool EncodeRSAPublicKey(const std::vector<uint8_t>& modulus_n, | 1000 static bool EncodeRSAPublicKey(const std::vector<uint8_t>& modulus_n, |
| 1000 const std::vector<uint8_t>& public_exponent_e, | 1001 const std::vector<uint8_t>& public_exponent_e, |
| 1001 std::vector<uint8_t>* public_key_info) { | 1002 std::vector<uint8_t>* public_key_info) { |
| 1002 // The public key is specified as the following ASN.1 structure: | 1003 // The public key is specified as the following ASN.1 structure: |
| 1003 // SubjectPublicKeyInfo ::= SEQUENCE { | 1004 // SubjectPublicKeyInfo ::= SEQUENCE { |
| 1004 // algorithm AlgorithmIdentifier, | 1005 // algorithm AlgorithmIdentifier, |
| 1005 // subjectPublicKey BIT STRING } | 1006 // subjectPublicKey BIT STRING } |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1136 &public_key_info[0], | 1137 &public_key_info[0], |
| 1137 public_key_info.size()); | 1138 public_key_info.size()); |
| 1138 signature[0] -= 1; | 1139 signature[0] -= 1; |
| 1139 ASSERT_TRUE(ok); | 1140 ASSERT_TRUE(ok); |
| 1140 verifier.VerifyUpdate(&message[0], message.size()); | 1141 verifier.VerifyUpdate(&message[0], message.size()); |
| 1141 ok = verifier.VerifyFinal(); | 1142 ok = verifier.VerifyFinal(); |
| 1142 EXPECT_FALSE(ok); | 1143 EXPECT_FALSE(ok); |
| 1143 } | 1144 } |
| 1144 } | 1145 } |
| 1145 } | 1146 } |
| OLD | NEW |