| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "net/cert/internal/signature_algorithm.h" | 5 #include "net/cert/internal/signature_algorithm.h" |
| 6 | 6 |
| 7 #include "net/der/input.h" | 7 #include "net/der/input.h" |
| 8 #include "net/der/parser.h" | 8 #include "net/der/parser.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 // From RFC 5912: | 14 // From RFC 5912: |
| 15 // | 15 // |
| 16 // sha1WithRSAEncryption OBJECT IDENTIFIER ::= { | 16 // sha1WithRSAEncryption OBJECT IDENTIFIER ::= { |
| 17 // iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) | 17 // iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) |
| 18 // pkcs-1(1) 5 } | 18 // pkcs-1(1) 5 } |
| 19 // | 19 // |
| 20 // In dotted notation: 1.2.840.113549.1.1.5 | 20 // In dotted notation: 1.2.840.113549.1.1.5 |
| 21 const uint8_t kOidSha1WithRsaEncryption[] = | 21 const uint8_t kOidSha1WithRsaEncryption[] = |
| 22 {0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05}; | 22 {0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05}; |
| 23 | 23 |
| 24 // sha1WithRSASignature is a deprecated equivalent of |
| 25 // sha1WithRSAEncryption. |
| 26 // |
| 27 // It originates from the NIST Open Systems Environment (OSE) |
| 28 // Implementor's Workshop (OIW). |
| 29 // |
| 30 // It is supported for compatibility with Microsoft's certificate APIs and |
| 31 // tools, particularly makecert.exe, which default(ed/s) to this OID for SHA-1. |
| 32 // |
| 33 // See also: https://bugzilla.mozilla.org/show_bug.cgi?id=1042479 |
| 34 // |
| 35 // In dotted notation: 1.3.14.3.2.29 |
| 36 const uint8_t kOidSha1WithRsaSignature[] = {0x2b, 0x0e, 0x03, 0x02, 0x1d}; |
| 37 |
| 24 // From RFC 5912: | 38 // From RFC 5912: |
| 25 // | 39 // |
| 26 // pkcs-1 OBJECT IDENTIFIER ::= | 40 // pkcs-1 OBJECT IDENTIFIER ::= |
| 27 // { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 1 } | 41 // { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 1 } |
| 28 | 42 |
| 29 // From RFC 5912: | 43 // From RFC 5912: |
| 30 // | 44 // |
| 31 // sha256WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 11 } | 45 // sha256WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 11 } |
| 32 // | 46 // |
| 33 // In dotted notation: 1.2.840.113549.1.1.11 | 47 // In dotted notation: 1.2.840.113549.1.1.11 |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 return ParseEcdsa(DigestAlgorithm::Sha256, params); | 303 return ParseEcdsa(DigestAlgorithm::Sha256, params); |
| 290 | 304 |
| 291 if (oid.Equals(der::Input(kOidEcdsaWithSha384))) | 305 if (oid.Equals(der::Input(kOidEcdsaWithSha384))) |
| 292 return ParseEcdsa(DigestAlgorithm::Sha384, params); | 306 return ParseEcdsa(DigestAlgorithm::Sha384, params); |
| 293 | 307 |
| 294 if (oid.Equals(der::Input(kOidEcdsaWithSha512))) | 308 if (oid.Equals(der::Input(kOidEcdsaWithSha512))) |
| 295 return ParseEcdsa(DigestAlgorithm::Sha512, params); | 309 return ParseEcdsa(DigestAlgorithm::Sha512, params); |
| 296 | 310 |
| 297 // TODO(eroman): Add parsing of RSASSA-PSS | 311 // TODO(eroman): Add parsing of RSASSA-PSS |
| 298 | 312 |
| 313 if (oid.Equals(der::Input(kOidSha1WithRsaSignature))) |
| 314 return ParseRsaPkcs1(DigestAlgorithm::Sha1, params); |
| 315 |
| 299 return nullptr; // Unsupported OID. | 316 return nullptr; // Unsupported OID. |
| 300 } | 317 } |
| 301 | 318 |
| 302 scoped_ptr<SignatureAlgorithm> SignatureAlgorithm::CreateRsaPkcs1( | 319 scoped_ptr<SignatureAlgorithm> SignatureAlgorithm::CreateRsaPkcs1( |
| 303 DigestAlgorithm digest) { | 320 DigestAlgorithm digest) { |
| 304 return make_scoped_ptr( | 321 return make_scoped_ptr( |
| 305 new SignatureAlgorithm(SignatureAlgorithmId::RsaPkcs1, digest, nullptr)); | 322 new SignatureAlgorithm(SignatureAlgorithmId::RsaPkcs1, digest, nullptr)); |
| 306 } | 323 } |
| 307 | 324 |
| 308 scoped_ptr<SignatureAlgorithm> SignatureAlgorithm::CreateEcdsa( | 325 scoped_ptr<SignatureAlgorithm> SignatureAlgorithm::CreateEcdsa( |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 } | 372 } |
| 356 | 373 |
| 357 SignatureAlgorithm::SignatureAlgorithm( | 374 SignatureAlgorithm::SignatureAlgorithm( |
| 358 SignatureAlgorithmId algorithm, | 375 SignatureAlgorithmId algorithm, |
| 359 DigestAlgorithm digest, | 376 DigestAlgorithm digest, |
| 360 scoped_ptr<SignatureAlgorithmParameters> params) | 377 scoped_ptr<SignatureAlgorithmParameters> params) |
| 361 : algorithm_(algorithm), digest_(digest), params_(params.Pass()) { | 378 : algorithm_(algorithm), digest_(digest), params_(params.Pass()) { |
| 362 } | 379 } |
| 363 | 380 |
| 364 } // namespace net | 381 } // namespace net |
| OLD | NEW |