GNUTLS_ERROR_ENTRY( GNUTLS_E_ILLEGAL_PARAMETER, 1),
GNUTLS_ERROR_ENTRY( GNUTLS_E_FILE, 1),
GNUTLS_ERROR_ENTRY( GNUTLS_E_ASCII_ARMOR, 1),
+ GNUTLS_ERROR_ENTRY( GNUTLS_E_UNIX_TIME_LIMIT_EXCEEDED, 1),
{0}
};
#define GNUTLS_E_DH_PRIME_UNACCEPTABLE -63
#define GNUTLS_E_FILE -64
#define GNUTLS_E_ASCII_ARMOR -65
+#define GNUTLS_E_UNIX_TIME_LIMIT_EXCEEDED -66
#define GNUTLS_E_UNIMPLEMENTED_FEATURE -250
ctime = _gnutls_utcTime2gtime(ttime);
}
+ /* We cannot handle dates after 2031 in 32 bit machines.
+ * a time_t of 64bits has to be used.
+ */
+
if (result != ASN_OK) {
gnutls_assert();
return (time_t) (-1);
len = sizeof(gversion) - 1;
if ((result = asn1_read_value(c2, name, gversion, &len)) < 0) {
gnutls_assert();
- return (-1);
+ return GNUTLS_E_ASN1_PARSING_ERROR;
}
return (int) gversion[0] + 1;
}
_gnutls_x509_get_time(c2, "certificate2", "notAfter");
gCert->activation_time =
_gnutls_x509_get_time(c2, "certificate2", "notBefore");
+
+ if (gCert->expiration_time == (time_t)(-1) ||
+ gCert->activation_time == (time_t)(-1)) {
+ gnutls_assert();
+ asn1_delete_structure(c2);
+ return GNUTLS_E_UNIX_TIME_LIMIT_EXCEEDED;
+ }
+
gCert->version = _gnutls_x509_get_version(c2, "certificate2");
+ if (gCert->version < 0) {
+ gnutls_assert();
+ asn1_delete_structure(c2);
+ return GNUTLS_E_ASN1_PARSING_ERROR;
+ }
if ((result =
_gnutls_get_ext_type(c2,
*
* Returns:
*
- * ASN_OK: the file has a correct syntax and every identifier is known.
- * ASN_FILE_NOT_FOUND: an error occured while opening FILE_NAME.
- * ASN_SYNTAX_ERROR: the syntax is not correct.
- * ASN_IDENTIFIER_NOT_FOUND: in the file there is an identifier that is not defined.
+ * ASN_OK\: the file has a correct syntax and every identifier is known.
+ *
+ * ASN_FILE_NOT_FOUND\: an error occured while opening FILE_NAME.
+ *
+ * ASN_SYNTAX_ERROR\: the syntax is not correct.
+ *
+ * ASN_IDENTIFIER_NOT_FOUND\: in the file there is an identifier that is not defined.
**/
int asn1_parser_asn1(char *file_name,node_asn **pointer){
p_tree=NULL;
*
* Returns:
*
- * ASN_OK: the file has a correct syntax and every identifier is known.
- * ASN_FILE_NOT_FOUND: an error occured while opening FILE_NAME.
- * ASN_SYNTAX_ERROR: the syntax is not correct.
- * ASN_IDENTIFIER_NOT_FOUND: in the file there is an identifier that is not defined.
+ * ASN_OK\: the file has a correct syntax and every identifier is known.
+ *
+ * ASN_FILE_NOT_FOUND\: an error occured while opening FILE_NAME.
+ *
+ * ASN_SYNTAX_ERROR\: the syntax is not correct.
+ *
+ * ASN_IDENTIFIER_NOT_FOUND\: in the file there is an identifier that is not defined.
**/
int asn1_parser_asn1_file_c(char *file_name){
int result;
#include "x509_asn1.h"
#include "x509_der.h"
#include <gnutls_str.h>
-
+#include <gnutls_errors.h>
/* define used for visiting trees */
#define UP 1
(!negative && (val[k]&0x80))) k--;
for(k2=k;k2<4;k2++) {
- if (k2-k > value_out_size-1) return ASN_MEM_ERROR;
+ if (k2-k > value_out_size-1) {
+ gnutls_assert();
+ return ASN_MEM_ERROR;
+ }
/* VALUE_OUT is too short to contain the value convertion */
value_out[k2-k]=val[k2];
}
#define PUT_VALUE( ptr, ptr_size, data, data_size) \
*len = data_size; \
if (ptr_size < data_size) { \
+ gnutls_assert(); \
return ASN_MEM_ERROR; \
} else { \
memcpy( ptr, data, data_size); \
#define PUT_STR_VALUE( ptr, ptr_size, data) \
*len = strlen(data) + 1; \
if (ptr_size < *len) { \
+ gnutls_assert(); \
return ASN_MEM_ERROR; \
} else { \
/* this strcpy is checked */ \
#define ADD_STR_VALUE( ptr, ptr_size, data) \
*len = strlen(data) + 1; \
if (ptr_size < strlen(ptr)+(*len)) { \
+ gnutls_assert(); \
return ASN_MEM_ERROR; \
} else { \
/* this strcat is checked */ \
#include "x509_der.h"
#include "x509_asn1.h"
#include <gnutls_str.h>
-
+#include <gnutls_errors.h>
#define TAG_BOOLEAN 0x01
#define TAG_INTEGER 0x02
if(str==NULL) return ASN_OK;
*str_len=_asn1_get_length_der(der,&len_len);
- if ( str_size > *str_len)
+ if ( str_size >= *str_len)
memcpy(str,der+len_len,*str_len);
- else return ASN_MEM_ERROR;
+ else {
+ gnutls_assert();
+ return ASN_MEM_ERROR;
+ }
*der_len=*str_len+len_len;
return ASN_OK;
if(str==NULL) return ASN_OK;
len_byte=_asn1_get_length_der(der,&len_len)-1;
- if (str_size > len_byte)
+ if (str_size >= len_byte)
memcpy(str,der+len_len+1,len_byte);
- else return ASN_MEM_ERROR;
-
+ else {
+ gnutls_assert();
+ return ASN_MEM_ERROR;
+ }
*bit_len=len_byte*8-der[len_len];
*der_len=len_byte+len_len+1;
/* get the issuer of 'cert'
*/
-
if (time(NULL) < cert->expiration_time)
ret = 0;
ret = check_if_expired( issuer);
if (ret != 0) {
gnutls_assert();
- return ret_else|GNUTLS_CERT_EXPIRED;
+ return ret_else | GNUTLS_CERT_EXPIRED;
}
ret = gnutls_x509_verify_signature(cert, issuer);