char state_or_province_name[X509_S_SIZE];
} gnutls_DN;
+#define X509KEY_DIGITAL_SIGNATURE 256
+#define X509KEY_NON_REPUDIATION 128
+#define X509KEY_KEY_ENCIPHERMENT 64
+#define X509KEY_DATA_ENCIPHERMENT 32
+#define X509KEY_KEY_AGREEMENT 16
+#define X509KEY_KEY_CERT_SIGN 8
+#define X509KEY_CRL_SIGN 4
+#define X509KEY_ENCIPHER_ONLY 2
+#define X509KEY_DECIPHER_ONLY 1
+
typedef struct {
MPI *params; /* the size of params depends on the public
time_t activation_time;
int version; /* 1,2,3
- */
+ */
+
+ int KeyUsage; /* bits from X509KEY_*
+ */
+
int valid; /* 0 if the certificate looks good.
*/
gnutls_datum raw; /* the raw certificate */
_gnutls_log( "GNUTLS ERROR: %s\n", ret);
- free( ret);
+ gnutls_free( ret);
}
* @error: is an error returned by a gnutls function. Error is always a negative value.
*
* This function is like strerror(). However it accepts an error returned by a gnutls
- * function. gnutls_strerror() returns a malloc'ed value thus
- * it should be free'd.
+ * function.
**/
const char* gnutls_strerror(int error)
{
GNUTLS_CipherSuite *newSuite;
int newSuiteSize = 0, i, j, keep;
const X509PKI_CREDENTIALS x509_cred;
- gnutls_cert *cert;
+ gnutls_cert *cert=NULL;
KXAlgorithm *alg;
int alg_size;
KXAlgorithm kx;
+ /* FIXME: remove algorithms depending on the KeyUsage bits
+ * eg.
+ * if (cert.KeyUsage & X509KEY_DIGITAL_SIGNATURE)
+ * we've got a sign-only key... (ok we need to check
+ * it more than that).
+ */
+
if (state->security_parameters.entity == GNUTLS_CLIENT)
- return 0; /* currently does nothing */
+ return 0;
/* if we should use a specific certificate,
* we should remove all algorithms that are not supported
extensions.dnsname);
}
- if (cert == NULL) { /* if no such cert, use the first in the list
+
+ if (cert == NULL && x509_cred->cert_list!=NULL) { /* if no such cert, use the first in the list
*/
cert = &x509_cred->cert_list[0][0];
- }
- /* get all the key exchange algorithms that are
- * supported by the certificate parameters.
- */
- if ((ret = _gnutls_cert_supported_kx(cert, &alg, &alg_size)) < 0) {
- gnutls_assert();
- return ret;
+ /* get all the key exchange algorithms that are
+ * supported by the X509 certificate parameters.
+ */
+ if ((ret = _gnutls_cert_supported_kx(cert, &alg, &alg_size)) < 0) {
+ gnutls_assert();
+ return ret;
+ }
+
+ } else {
+ /* No certificate was found
+ */
+ alg_size = 0;
+ alg = NULL;
}
+
newSuite =
gnutls_malloc(numCipherSuites * sizeof(GNUTLS_CipherSuite));