| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Various SSL functions. | 2 * Various SSL functions. |
| 3 * | 3 * |
| 4 * ***** BEGIN LICENSE BLOCK ***** | 4 * This Source Code Form is subject to the terms of the Mozilla Public |
| 5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 5 * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 6 * | 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 7 * The contents of this file are subject to the Mozilla Public License Version | 7 /* $Id: sslsecur.c,v 1.61 2012/05/24 20:34:51 wtc%google.com Exp $ */ |
| 8 * 1.1 (the "License"); you may not use this file except in compliance with | |
| 9 * the License. You may obtain a copy of the License at | |
| 10 * http://www.mozilla.org/MPL/ | |
| 11 * | |
| 12 * Software distributed under the License is distributed on an "AS IS" basis, | |
| 13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |
| 14 * for the specific language governing rights and limitations under the | |
| 15 * License. | |
| 16 * | |
| 17 * The Original Code is the Netscape security libraries. | |
| 18 * | |
| 19 * The Initial Developer of the Original Code is | |
| 20 * Netscape Communications Corporation. | |
| 21 * Portions created by the Initial Developer are Copyright (C) 1994-2000 | |
| 22 * the Initial Developer. All Rights Reserved. | |
| 23 * | |
| 24 * Contributor(s): | |
| 25 * Dr Vipul Gupta <vipul.gupta@sun.com>, Sun Microsystems Laboratories | |
| 26 * | |
| 27 * Alternatively, the contents of this file may be used under the terms of | |
| 28 * either the GNU General Public License Version 2 or later (the "GPL"), or | |
| 29 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), | |
| 30 * in which case the provisions of the GPL or the LGPL are applicable instead | |
| 31 * of those above. If you wish to allow use of your version of this file only | |
| 32 * under the terms of either the GPL or the LGPL, and not to allow others to | |
| 33 * use your version of this file under the terms of the MPL, indicate your | |
| 34 * decision by deleting the provisions above and replace them with the notice | |
| 35 * and other provisions required by the GPL or the LGPL. If you do not delete | |
| 36 * the provisions above, a recipient may use your version of this file under | |
| 37 * the terms of any one of the MPL, the GPL or the LGPL. | |
| 38 * | |
| 39 * ***** END LICENSE BLOCK ***** */ | |
| 40 /* $Id: sslsecur.c,v 1.58 2012/03/01 18:36:35 kaie%kuix.de Exp $ */ | |
| 41 #include "cert.h" | 8 #include "cert.h" |
| 42 #include "secitem.h" | 9 #include "secitem.h" |
| 43 #include "keyhi.h" | 10 #include "keyhi.h" |
| 44 #include "ssl.h" | 11 #include "ssl.h" |
| 45 #include "sslimpl.h" | 12 #include "sslimpl.h" |
| 46 #include "sslproto.h" | 13 #include "sslproto.h" |
| 47 #include "secoid.h" /* for SECOID_GetALgorithmTag */ | 14 #include "secoid.h" /* for SECOID_GetALgorithmTag */ |
| 48 #include "pk11func.h" /* for PK11_GenerateRandom */ | 15 #include "pk11func.h" /* for PK11_GenerateRandom */ |
| 49 #include "nss.h" /* for NSS_RegisterShutdown */ | 16 #include "nss.h" /* for NSS_RegisterShutdown */ |
| 50 #include "prinit.h" /* for PR_CallOnceWithArg */ | 17 #include "prinit.h" /* for PR_CallOnceWithArg */ |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 SSL_GETPID(), ss->fd, amount, available)); | 589 SSL_GETPID(), ss->fd, amount, available)); |
| 623 PRINT_BUF(4, (ss, "DoRecv receiving plaintext:", out, amount)); | 590 PRINT_BUF(4, (ss, "DoRecv receiving plaintext:", out, amount)); |
| 624 | 591 |
| 625 done: | 592 done: |
| 626 ssl_ReleaseRecvBufLock(ss); | 593 ssl_ReleaseRecvBufLock(ss); |
| 627 return rv; | 594 return rv; |
| 628 } | 595 } |
| 629 | 596 |
| 630 /************************************************************************/ | 597 /************************************************************************/ |
| 631 | 598 |
| 599 /* |
| 600 ** Return SSLKEAType derived from cert's Public Key algorithm info. |
| 601 */ |
| 632 SSLKEAType | 602 SSLKEAType |
| 633 ssl_FindCertKEAType(CERTCertificate * cert) | 603 NSS_FindCertKEAType(CERTCertificate * cert) |
| 634 { | 604 { |
| 635 SSLKEAType keaType = kt_null; | 605 SSLKEAType keaType = kt_null; |
| 636 int tag; | 606 int tag; |
| 637 | 607 |
| 638 if (!cert) goto loser; | 608 if (!cert) goto loser; |
| 639 | 609 |
| 640 tag = SECOID_GetAlgorithmTag(&(cert->subjectPublicKeyInfo.algorithm)); | 610 tag = SECOID_GetAlgorithmTag(&(cert->subjectPublicKeyInfo.algorithm)); |
| 641 | 611 |
| 642 switch (tag) { | 612 switch (tag) { |
| 643 case SEC_OID_X500_RSA_ENCRYPTION: | 613 case SEC_OID_X500_RSA_ENCRYPTION: |
| 644 case SEC_OID_PKCS1_RSA_ENCRYPTION: | 614 case SEC_OID_PKCS1_RSA_ENCRYPTION: |
| 645 keaType = kt_rsa; | 615 keaType = kt_rsa; |
| 646 break; | 616 break; |
| 647 | |
| 648 case SEC_OID_X942_DIFFIE_HELMAN_KEY: | 617 case SEC_OID_X942_DIFFIE_HELMAN_KEY: |
| 649 keaType = kt_dh; | 618 keaType = kt_dh; |
| 650 break; | 619 break; |
| 651 #ifdef NSS_ENABLE_ECC | 620 #ifdef NSS_ENABLE_ECC |
| 652 case SEC_OID_ANSIX962_EC_PUBLIC_KEY: | 621 case SEC_OID_ANSIX962_EC_PUBLIC_KEY: |
| 653 keaType = kt_ecdh; | 622 keaType = kt_ecdh; |
| 654 break; | 623 break; |
| 655 #endif /* NSS_ENABLE_ECC */ | 624 #endif /* NSS_ENABLE_ECC */ |
| 656 default: | 625 default: |
| 657 keaType = kt_null; | 626 keaType = kt_null; |
| 658 } | 627 } |
| 659 | 628 |
| 660 loser: | 629 loser: |
| 661 | 630 |
| 662 return keaType; | 631 return keaType; |
| 663 | |
| 664 } | 632 } |
| 665 | 633 |
| 666 static const PRCallOnceType pristineCallOnce; | 634 static const PRCallOnceType pristineCallOnce; |
| 667 static PRCallOnceType setupServerCAListOnce; | 635 static PRCallOnceType setupServerCAListOnce; |
| 668 | 636 |
| 669 static SECStatus serverCAListShutdown(void* appData, void* nssData) | 637 static SECStatus serverCAListShutdown(void* appData, void* nssData) |
| 670 { | 638 { |
| 671 PORT_Assert(ssl3_server_ca_list); | 639 PORT_Assert(ssl3_server_ca_list); |
| 672 if (ssl3_server_ca_list) { | 640 if (ssl3_server_ca_list) { |
| 673 CERT_FreeDistNames(ssl3_server_ca_list); | 641 CERT_FreeDistNames(ssl3_server_ca_list); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 763 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
| 796 return SECFailure; | 764 return SECFailure; |
| 797 } | 765 } |
| 798 | 766 |
| 799 /* make sure the key exchange is recognized */ | 767 /* make sure the key exchange is recognized */ |
| 800 if ((kea >= kt_kea_size) || (kea < kt_null)) { | 768 if ((kea >= kt_kea_size) || (kea < kt_null)) { |
| 801 PORT_SetError(SEC_ERROR_UNSUPPORTED_KEYALG); | 769 PORT_SetError(SEC_ERROR_UNSUPPORTED_KEYALG); |
| 802 return SECFailure; | 770 return SECFailure; |
| 803 } | 771 } |
| 804 | 772 |
| 805 if (kea != ssl_FindCertKEAType(cert)) { | 773 if (kea != NSS_FindCertKEAType(cert)) { |
| 806 PORT_SetError(SSL_ERROR_CERT_KEA_MISMATCH); | 774 PORT_SetError(SSL_ERROR_CERT_KEA_MISMATCH); |
| 807 return SECFailure; | 775 return SECFailure; |
| 808 } | 776 } |
| 809 | 777 |
| 810 if (cert) { | 778 if (cert) { |
| 811 /* get the size of the cert's public key, and remember it */ | 779 /* get the size of the cert's public key, and remember it */ |
| 812 pubKey = CERT_ExtractPublicKey(cert); | 780 pubKey = CERT_ExtractPublicKey(cert); |
| 813 if (!pubKey) | 781 if (!pubKey) |
| 814 return SECFailure; | 782 return SECFailure; |
| 815 } | 783 } |
| (...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1622 if (!ss) { | 1590 if (!ss) { |
| 1623 SSL_DBG(("%d: SSL[%d]: bad socket in SNISocketConfigHook", | 1591 SSL_DBG(("%d: SSL[%d]: bad socket in SNISocketConfigHook", |
| 1624 SSL_GETPID(), fd)); | 1592 SSL_GETPID(), fd)); |
| 1625 return SECFailure; | 1593 return SECFailure; |
| 1626 } | 1594 } |
| 1627 | 1595 |
| 1628 ss->sniSocketConfig = func; | 1596 ss->sniSocketConfig = func; |
| 1629 ss->sniSocketConfigArg = arg; | 1597 ss->sniSocketConfigArg = arg; |
| 1630 return SECSuccess; | 1598 return SECSuccess; |
| 1631 } | 1599 } |
| OLD | NEW |