]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
CertificateType is now accesible from the API.
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Tue, 29 Jan 2002 16:09:52 +0000 (16:09 +0000)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Tue, 29 Jan 2002 16:09:52 +0000 (16:09 +0000)
lib/auth_cert.c
lib/gnutls.h.in.in
lib/gnutls_cert.h
lib/gnutls_int.h
lib/gnutls_record.c
lib/gnutls_record.h
lib/gnutls_state.c
lib/gnutls_state.h

index a04fd02ffc892b1a20fb14942e002b42a7507b78..7ed3eccf9fa0ad28c9c3353bc2819fcaf39a9395 100644 (file)
@@ -282,7 +282,7 @@ static int _gnutls_find_acceptable_client_cert(GNUTLS_STATE state,
                                                pk_algos, pk_algos_length,
                                                cred->cert_list[i][0].subject_pk_algorithm)==0)
                                        && (cred->cert_list[i][0].cert_type ==
-                                               _gnutls_state_cert_type_get( state))) {
+                                               gnutls_cert_type_get( state))) {
                                                indx = i;
                                                break;
                                        }
@@ -315,7 +315,7 @@ static int _gnutls_find_acceptable_client_cert(GNUTLS_STATE state,
                /* put the requested DNs to req_dn, only in case
                 * of X509 certificates.
                 */
-               if ( _gnutls_state_cert_type_get(state) == GNUTLS_CRT_X509) {
+               if ( gnutls_cert_type_get(state) == GNUTLS_CRT_X509) {
                        data = _data;
                        data_size = _data_size;
                        count = 0;      /* holds the number of given CA's DN */
@@ -362,7 +362,7 @@ static int _gnutls_find_acceptable_client_cert(GNUTLS_STATE state,
                 */
                for (j = i = 0; i < cred->ncerts; i++) {
                        if ( (cred->cert_list[i][0].cert_type ==
-                            _gnutls_state_cert_type_get( state)) &&
+                            gnutls_cert_type_get( state)) &&
                             (_gnutls_check_pk_algo_in_list( pk_algos, 
                             pk_algos_length,
                             cred->cert_list[i][0].subject_pk_algorithm)==0)) {
@@ -867,7 +867,7 @@ int _gnutls_gen_x509_server_cert_req(GNUTLS_STATE state, opaque ** data)
                return GNUTLS_E_INSUFICIENT_CRED;
        }
 
-       size = CERTTYPE_SIZE + 2;       /* 2 for CertType + 2 for size of rdn_seq 
+       size = CERTTYPE_SIZE + 2;       /* 2 for CertificateType + 2 for size of rdn_seq 
                                         */
 
        size += cred->x509_rdn_sequence.size;
@@ -1483,7 +1483,7 @@ int _gnutls_server_find_x509_cert_list_index(GNUTLS_STATE state,
                        requested_algo==cred->cert_list[i][0].subject_pk_algorithm) {
                                
                                /* if cert type matches */
-                               if ( _gnutls_state_cert_type_get( state) ==
+                               if ( gnutls_cert_type_get( state) ==
                                        cred->cert_list[i][0].cert_type) {
 
                                        index = i;
@@ -1513,7 +1513,7 @@ int _gnutls_server_find_x509_cert_list_index(GNUTLS_STATE state,
                                requested_algo==cred->cert_list[i][0].subject_pk_algorithm) {
                                        
                                        /* if cert type matches */
-                                       if ( _gnutls_state_cert_type_get( state) ==
+                                       if ( gnutls_cert_type_get( state) ==
                                                cred->cert_list[i][0].cert_type) {
 
                                                ij_map[j] = i;
index 36ff3ee8a8b517fb0affe20aceb0bf6b14579e4e..b6acc467f4c98eb7fb138ac31f38c6f5cdf1c01c 100644 (file)
@@ -66,6 +66,10 @@ typedef enum GNUTLS_CloseRequest { GNUTLS_SHUT_RDWR=0, GNUTLS_SHUT_WR=1 } GNUTLS
 
 typedef enum GNUTLS_Version { GNUTLS_SSL3=1, GNUTLS_TLS1 } GNUTLS_Version;
 
+typedef enum GNUTLS_CertificateType { GNUTLS_CRT_X509=1, GNUTLS_CRT_OPENPGP 
+} GNUTLS_CertificateType;
+
+
 /* If you want to change this, then also change the 
  * define in gnutls_int.h, and recompile.
  */
@@ -97,10 +101,11 @@ int                 gnutls_alert_send( GNUTLS_STATE, GNUTLS_AlertLevel, GNUTLS_AlertDescripti
 int             gnutls_alert_send_appropriate(  GNUTLS_STATE state, int err);
 
 /* get information on the current state */
-GNUTLS_BulkCipherAlgorithm gnutls_cipher_get( GNUTLS_STATE state);
-GNUTLS_KXAlgorithm         gnutls_kx_get( GNUTLS_STATE state);
-GNUTLS_MACAlgorithm        gnutls_mac_get( GNUTLS_STATE state);
-GNUTLS_CompressionMethod   gnutls_compression_get( GNUTLS_STATE state);
+GNUTLS_BulkCipherAlgorithm     gnutls_cipher_get( GNUTLS_STATE state);
+GNUTLS_KXAlgorithm             gnutls_kx_get( GNUTLS_STATE state);
+GNUTLS_MACAlgorithm            gnutls_mac_get( GNUTLS_STATE state);
+GNUTLS_CompressionMethod       gnutls_compression_get( GNUTLS_STATE state);
+GNUTLS_CertificateType         gnutls_cert_type_get( GNUTLS_STATE state);
 
 /* the name of the specified algorithms */
 const char *gnutls_cipher_get_name( GNUTLS_BulkCipherAlgorithm);
index eacf51c157fd9a32c1f39f5b13ea2fe1dfe9fadc..00ea31e8cd1f7f406023997b1c826b9e874e930c 100644 (file)
@@ -52,7 +52,7 @@ typedef struct gnutls_cert {
 
                        /* holds the type (PGP, X509)
                         */
-       CertType     cert_type;
+       CertificateType     cert_type;
        gnutls_datum raw; /* the raw certificate */
 } gnutls_cert;
 
index d8ed09906a4e891373c7f146c0aee3cfe667db2e..cd29c2ca5dc894451ca82b8ec8cc8d24d7e0bc42 100644 (file)
@@ -180,9 +180,9 @@ typedef enum KXAlgorithm { GNUTLS_KX_RSA=1, GNUTLS_KX_DHE_DSS,
 } KXAlgorithm;
 #define GNUTLS_KXAlgorithm KXAlgorithm
 
-typedef enum CertType { GNUTLS_CRT_X509=1, GNUTLS_CRT_OPENPGP 
-} CertType;
-#define GNUTLS_CertType CertType
+typedef enum CertificateType { GNUTLS_CRT_X509=1, GNUTLS_CRT_OPENPGP 
+} CertificateType;
+#define GNUTLS_CertificateType CertificateType
 
 typedef enum CredType { GNUTLS_CRD_CERTIFICATE=1, GNUTLS_CRD_ANON, GNUTLS_CRD_SRP 
 } CredType;
@@ -348,7 +348,7 @@ typedef struct {
        TLSExtensions           extensions;
        uint16                  max_record_size;
        /* holds the negotiated certificate type */
-       CertType                cert_type;      
+       CertificateType         cert_type;      
        GNUTLS_Version          version; /* moved here */
 } SecurityParameters;
 
index 3a2effab577b7d36e50bc175d53ffbba7dd627a2..e018be37ba35787ccbf3a9ff6a44f58514d51137 100644 (file)
@@ -989,45 +989,6 @@ ssize_t gnutls_recv_int( GNUTLS_STATE state, ContentType type, HandshakeType hty
        return ret;
 }
 
-/**
-  * gnutls_cipher_get - Returns the currently used cipher.
-  * @state: is a &GNUTLS_STATE structure.
-  *
-  * Returns the currently used cipher.
-  **/
-GNUTLS_BulkCipherAlgorithm gnutls_cipher_get( GNUTLS_STATE state) {
-       return state->security_parameters.read_bulk_cipher_algorithm;
-}
-
-/**
-  * gnutls_kx_get - Returns the key exchange algorithm.
-  * @state: is a &GNUTLS_STATE structure.
-  *
-  * Returns the key exchange algorithm used in the last handshake.
-  **/
-GNUTLS_KXAlgorithm gnutls_kx_get( GNUTLS_STATE state) {
-       return state->security_parameters.kx_algorithm;
-}
-
-/**
-  * gnutls_mac_get - Returns the currently used mac algorithm.
-  * @state: is a &GNUTLS_STATE structure.
-  *
-  * Returns the currently used mac algorithm.
-  **/
-GNUTLS_MACAlgorithm gnutls_mac_get( GNUTLS_STATE state) {
-       return state->security_parameters.read_mac_algorithm;
-}
-
-/**
-  * gnutls_compression_get - Returns the currently used compression algorithm.
-  * @state: is a &GNUTLS_STATE structure.
-  *
-  * Returns the currently used compression method.
-  **/
-GNUTLS_CompressionMethod gnutls_compression_get( GNUTLS_STATE state) {
-       return state->security_parameters.read_compression_algorithm;
-}
 
 /* Taken from libgcrypt */
 
index 58a7bd589e6d27fdfa9836bc27d3470d0ba99db0..a9bf8ea64dec506c3e27a497e4e04a823572f1e7 100644 (file)
@@ -1,4 +1,3 @@
-KXAlgorithm gnutls_kx_get( GNUTLS_STATE state);
 ssize_t gnutls_send_int( GNUTLS_STATE state, ContentType type, HandshakeType htype, const void* data, size_t sizeofdata);
 ssize_t gnutls_recv_int( GNUTLS_STATE state, ContentType type, HandshakeType, char* data, size_t sizeofdata);
 ssize_t _gnutls_send_change_cipher_spec( GNUTLS_STATE state, int again);
index 7dc12269c665155e5e44635c8462a21c5032d10e..8e21420813af61cc35a3ea5ff3a4ff9610edfc8c 100644 (file)
  */
 
 #include <gnutls_int.h>
+#include <gnutls_errors.h>
+#include <gnutls_auth_int.h>
 
-CertType _gnutls_state_cert_type_get( GNUTLS_STATE state) {
+#define CHECK_AUTH(auth, ret) if (gnutls_auth_get_type(state) != auth) { \
+       gnutls_assert(); \
+       return ret; \
+       }
+
+void _gnutls_state_cert_type_set( GNUTLS_STATE state, CertificateType ct) {
+       state->security_parameters.cert_type = ct;
+}
+
+/**
+  * gnutls_cipher_get - Returns the currently used cipher.
+  * @state: is a &GNUTLS_STATE structure.
+  *
+  * Returns the currently used cipher.
+  **/
+GNUTLS_BulkCipherAlgorithm gnutls_cipher_get( GNUTLS_STATE state) {
+       return state->security_parameters.read_bulk_cipher_algorithm;
+}
+
+/**
+  * gnutls_cert_type_get - Returns the currently used certificate type.
+  * @state: is a &GNUTLS_STATE structure.
+  *
+  * Returns the currently used certificate type. The certificate type
+  * is by default X.509, unless it is negotiated as a TLS extension.
+  *
+  **/
+GNUTLS_CertificateType gnutls_cert_type_get( GNUTLS_STATE state) {
        return state->security_parameters.cert_type;
 }
 
-void _gnutls_state_cert_type_set( GNUTLS_STATE state, CertType ct) {
-       state->security_parameters.cert_type = ct;
+/**
+  * gnutls_kx_get - Returns the key exchange algorithm.
+  * @state: is a &GNUTLS_STATE structure.
+  *
+  * Returns the key exchange algorithm used in the last handshake.
+  **/
+GNUTLS_KXAlgorithm gnutls_kx_get( GNUTLS_STATE state) {
+       return state->security_parameters.kx_algorithm;
+}
+
+/**
+  * gnutls_mac_get - Returns the currently used mac algorithm.
+  * @state: is a &GNUTLS_STATE structure.
+  *
+  * Returns the currently used mac algorithm.
+  **/
+GNUTLS_MACAlgorithm gnutls_mac_get( GNUTLS_STATE state) {
+       return state->security_parameters.read_mac_algorithm;
+}
+
+/**
+  * gnutls_compression_get - Returns the currently used compression algorithm.
+  * @state: is a &GNUTLS_STATE structure.
+  *
+  * Returns the currently used compression method.
+  **/
+GNUTLS_CompressionMethod gnutls_compression_get( GNUTLS_STATE state) {
+       return state->security_parameters.read_compression_algorithm;
 }
index 1305e9b4cdfc0a251a73a11760d8a96112afe41d..3138ed970109d19399acbfb2ab1f9445e3640640 100644 (file)
@@ -3,8 +3,9 @@
 
 #include <gnutls_int.h>
 
-CertType _gnutls_state_cert_type_get( GNUTLS_STATE state);
-void _gnutls_state_cert_type_set( GNUTLS_STATE state, CertType);
+void _gnutls_state_cert_type_set( GNUTLS_STATE state, CertificateType);
+KXAlgorithm gnutls_kx_get( GNUTLS_STATE state);
+CertificateType gnutls_cert_type_get( GNUTLS_STATE state);
 
 
 #endif