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

Side by Side Diff: net/cert/x509_util_openssl.cc

Issue 2728953003: Add support for MD2, MD4, and MD5 to SignatureAlgorithm. (Closed)
Patch Set: wow. dumb Created 3 years, 9 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
OLDNEW
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 "net/cert/x509_util_openssl.h" 5 #include "net/cert/x509_util_openssl.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 &signature_value, nullptr)) 332 &signature_value, nullptr))
333 return false; 333 return false;
334 334
335 std::unique_ptr<SignatureAlgorithm> signature_algorithm = 335 std::unique_ptr<SignatureAlgorithm> signature_algorithm =
336 SignatureAlgorithm::Create(signature_algorithm_tlv, nullptr); 336 SignatureAlgorithm::Create(signature_algorithm_tlv, nullptr);
337 if (!signature_algorithm) 337 if (!signature_algorithm)
338 return false; 338 return false;
339 339
340 const EVP_MD* digest_evp_md = nullptr; 340 const EVP_MD* digest_evp_md = nullptr;
341 switch (signature_algorithm->digest()) { 341 switch (signature_algorithm->digest()) {
342 case net::DigestAlgorithm::Md2:
343 case net::DigestAlgorithm::Md4:
344 // Shouldn't be reachable.
345 digest_evp_md = nullptr;
346 break;
347
348 // Per RFC 5929 section 4.1, MD5 and SHA1 map to SHA256.
349 case net::DigestAlgorithm::Md5:
342 case net::DigestAlgorithm::Sha1: 350 case net::DigestAlgorithm::Sha1:
343 case net::DigestAlgorithm::Sha256: 351 case net::DigestAlgorithm::Sha256:
344 digest_evp_md = EVP_sha256(); 352 digest_evp_md = EVP_sha256();
345 break; 353 break;
346 354
347 case net::DigestAlgorithm::Sha384: 355 case net::DigestAlgorithm::Sha384:
348 digest_evp_md = EVP_sha384(); 356 digest_evp_md = EVP_sha384();
349 break; 357 break;
350 358
351 case net::DigestAlgorithm::Sha512: 359 case net::DigestAlgorithm::Sha512:
(...skipping 29 matching lines...) Expand all
381 bssl::UniquePtr<CRYPTO_BUFFER> CreateCryptoBuffer( 389 bssl::UniquePtr<CRYPTO_BUFFER> CreateCryptoBuffer(
382 const base::StringPiece& data) { 390 const base::StringPiece& data) {
383 return bssl::UniquePtr<CRYPTO_BUFFER>( 391 return bssl::UniquePtr<CRYPTO_BUFFER>(
384 CRYPTO_BUFFER_new(reinterpret_cast<const uint8_t*>(data.data()), 392 CRYPTO_BUFFER_new(reinterpret_cast<const uint8_t*>(data.data()),
385 data.size(), GetBufferPool())); 393 data.size(), GetBufferPool()));
386 } 394 }
387 395
388 } // namespace x509_util 396 } // namespace x509_util
389 397
390 } // namespace net 398 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698