#include "gnutls_num.h"
#include "ext_cert_type.h"
#include <gnutls_state.h>
+#include <gnutls_num.h>
/*
* In case of a server: if a CERT_TYPE extension type is received then it stores
}
} else { /* SERVER SIDE - we must check if the sent cert type is the right one
*/
- if (data_size > 0) {
+ if (data_size > 1) {
+ uint8 len;
- if ( data_size <= 0) {
- gnutls_assert();
- return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
- }
+ len = data[0];
+ DECR_LEN( data_size, len);
- for (i=0;i<data_size;i++) {
- new_type = _gnutls_num2cert_type(data[i]);
+ for (i=0;i<len;i++) {
+ new_type = _gnutls_num2cert_type(data[i+1]);
if (new_type < 0) continue;
return 0;
}
- if (data_size < len) {
+ if (data_size < len + 1) {
gnutls_assert();
return GNUTLS_E_INVALID_REQUEST;
}
+
+ /* this is a vector!
+ */
+ data[0] = (uint8) len;
for (i=0;i<len;i++) {
- data[i] = _gnutls_cert_type2num( session->internals.
+ data[i+1] = _gnutls_cert_type2num( session->internals.
cert_type_priority.priority[i]);
}
- return len;
+ return len + 1;
}
} else { /* server side */
*/
typedef int gnutls_transport_ptr;
-typedef const int* gnutls_list;
-
#define MIN_BITS 767
#define MAX32 4294967295
#define TLS_RANDOM_SIZE 32
#define TLS_MAX_SESSION_ID_SIZE 32
#define TLS_MASTER_SIZE 48
+
+/* The maximum digest size of hash algorithms.
+ */
#define MAX_HASH_SIZE 20
#define MAX_X509_CERT_SIZE 10*1024
}
-/* Returns 0 if it's ok to use the gnutls_kx_algorithm with this cert
- * (using KeyUsage field).
+/* Returns 0 if it's ok to use the gnutls_kx_algorithm with this
+ * certificate (uses the KeyUsage field).
*/
int _gnutls_check_x509_key_usage(const gnutls_cert * cert,
gnutls_kx_algorithm alg)
return 0;
case GNUTLS_KX_DHE_RSA:
case GNUTLS_KX_DHE_DSS:
+ case GNUTLS_KX_RSA_EXPORT:
if (cert->keyUsage != 0) {
if (!
(cert->
return 0;
}
return 0;
-
- case GNUTLS_KX_RSA_EXPORT:
- return 0;
-
default:
gnutls_assert();
return GNUTLS_E_X509_KEY_USAGE_VIOLATION;