OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ssl/openssl_platform_key.h" | 5 #include "net/ssl/openssl_platform_key.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <NCrypt.h> | 8 #include <NCrypt.h> |
9 | 9 |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 } | 499 } |
500 sig->r = BN_bin2bn(&raw_sig[0], degree, nullptr); | 500 sig->r = BN_bin2bn(&raw_sig[0], degree, nullptr); |
501 sig->s = BN_bin2bn(&raw_sig[degree], degree, nullptr); | 501 sig->s = BN_bin2bn(&raw_sig[degree], degree, nullptr); |
502 if (!sig->r || !sig->s) { | 502 if (!sig->r || !sig->s) { |
503 OpenSSLPutNetError(FROM_HERE, ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED); | 503 OpenSSLPutNetError(FROM_HERE, ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED); |
504 return 0; | 504 return 0; |
505 } | 505 } |
506 | 506 |
507 // Ensure the DER-encoded signature fits in the bounds. | 507 // Ensure the DER-encoded signature fits in the bounds. |
508 int len = i2d_ECDSA_SIG(sig.get(), nullptr); | 508 int len = i2d_ECDSA_SIG(sig.get(), nullptr); |
509 if (len < 0 || static_cast<size_t>(len) > ECDSA_size(ec_key)) { | 509 if (len < 0 || len > ECDSA_size(ec_key)) { |
510 OpenSSLPutNetError(FROM_HERE, ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED); | 510 OpenSSLPutNetError(FROM_HERE, ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED); |
511 return 0; | 511 return 0; |
512 } | 512 } |
513 | 513 |
514 len = i2d_ECDSA_SIG(sig.get(), &out_sig); | 514 len = i2d_ECDSA_SIG(sig.get(), &out_sig); |
515 if (len < 0) { | 515 if (len < 0) { |
516 OpenSSLPutNetError(FROM_HERE, ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED); | 516 OpenSSLPutNetError(FROM_HERE, ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED); |
517 return 0; | 517 return 0; |
518 } | 518 } |
519 *out_sig_len = len; | 519 *out_sig_len = len; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 case EVP_PKEY_RSA: | 701 case EVP_PKEY_RSA: |
702 return CreateRSAWrapper(key.Pass(), key_length); | 702 return CreateRSAWrapper(key.Pass(), key_length); |
703 case EVP_PKEY_EC: | 703 case EVP_PKEY_EC: |
704 return CreateECDSAWrapper(key.Pass(), key_length); | 704 return CreateECDSAWrapper(key.Pass(), key_length); |
705 default: | 705 default: |
706 return nullptr; | 706 return nullptr; |
707 } | 707 } |
708 } | 708 } |
709 | 709 |
710 } // namespace net | 710 } // namespace net |
OLD | NEW |