* gnutls_fingerprint - This function calculates the fingerprint of the given data
* @algo: is a digest algorithm
* @data: is the data
- * @result: is the place where the result will be copied.
+ * @result: is the place where the result will be copied (may be null).
* @result_size: should hold the size of the result. The actual size
* of the returned result will also be copied there.
*
return GNUTLS_E_SHORT_MEMORY_BUFFER;
}
*result_size = hash_len;
+
+ if (result) {
+ td = _gnutls_hash_init( algo);
+ if (td==NULL) return GNUTLS_E_HASH_FAILED;
- td = _gnutls_hash_init( algo);
- if (td==NULL) return GNUTLS_E_HASH_FAILED;
-
- _gnutls_hash( td, data->data, data->size);
+ _gnutls_hash( td, data->data, data->size);
- _gnutls_hash_deinit( td, result);
+ _gnutls_hash_deinit( td, result);
+ }
return 0;
}
GNUTLS_E_SHORT_MEMORY_BUFFER;
}
*sizeof_buf = size; /* -1 for the null +1 for the '#' */
- strcpy(buf, "#");
- strcat(buf, res);
+
+ if (buf) {
+ strcpy(buf, "#");
+ strcat(buf, res);
+ }
return 0;
} else {
*
**/
int gnutls_pkcs7_get_certificate(gnutls_pkcs7 pkcs7,
- int indx, char* certificate, int* certificate_size)
+ int indx, unsigned char* certificate, int* certificate_size)
{
ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
int result, len;
end = end-start+1;
- if (certificate!=NULL && end <= *certificate_size)
- memcpy( certificate, &tmp[start], end);
- else {
+ if ( end > *certificate_size) {
*certificate_size = end;
result = GNUTLS_E_SHORT_MEMORY_BUFFER;
goto cleanup;
}
+ if (certificate)
+ memcpy( certificate, &tmp[start], end);
+
*certificate_size = end;
result = 0;
int gnutls_pkcs7_import(gnutls_pkcs7 pkcs7, const gnutls_datum * data,
gnutls_x509_crt_fmt format);
int gnutls_pkcs7_get_certificate(gnutls_pkcs7 pkcs7,
- int indx, char* certificate, int* certificate_size);
+ int indx, unsigned char* certificate, int* certificate_size);
int gnutls_pkcs7_get_certificate_count(gnutls_pkcs7 pkcs7);
}
*sizeof_buf = output.size;
- memcpy( buf, output.data, output.size);
+
+ if (buf)
+ memcpy( buf, output.data, output.size);
_gnutls_free_datum( &output);
tmp.data = cert_buf;
tmp.size = cert_buf_size;
+
return gnutls_fingerprint( algo, &tmp, buf, sizeof_buf);
}