#define gnutls_x509pki_client_get_peer_certificate_status gnutls_x509pki_get_peer_certificate_status
#define gnutls_x509pki_client_get_peer_certificate_list gnutls_x509pki_get_peer_certificate_list
+int gnutls_b64_encode( const char* msg, const gnutls_datum *data, char* result, int* result_size);
+int gnutls_b64_decode( const gnutls_datum *b64_data, char* result, int* result_size);
+
# endif /* LIBGNUTLS_VERSION */
#endif /* GNUTLS_UI_H */
return ret;
}
+/**
+ * gnutls_b64_encode - This function will convert DER data to Base64 encoded
+ * @msg: is a message to be put in the header
+ * @data: contain the DER data
+ * @result: the place where base64 data will be copied
+ * @result_size: holds the size of the result
+ *
+ * This function will convert the given data to printable data, using the base64
+ * encoding.
+ *
+ **/
+int gnutls_b64_encode( const char* msg, const gnutls_datum *data, char* result, int* result_size) {
+opaque* ret;
+int size;
+
+ size = _gnutls_fbase64_encode( msg, pem_data->data, pem_data->size, &ret);
+ if (size < 0)
+ return size;
+
+ if (result==NULL || *result_size < size) {
+ gnutls_free(ret);
+ *result_size = size;
+ return GNUTLS_E_INVALID_REQUEST;
+ } else {
+ memcpy( result, ret, size);
+ gnutls_free(ret);
+ *result_size = size;
+ }
+
+ return 0;
+}
+
/* encodes data and puts the result into result (localy alocated)
* The result_size is the return value
*/
-int _gnutls_fbase64_encode(char *msg, uint8 * data, int data_size,
+int _gnutls_fbase64_encode(const char *msg, const uint8 * data, int data_size,
uint8 ** result)
{
int i, ret, tmp, j;
return j;
}
+/**
+ * gnutls_b64_decode - This function will decode base64 encoded data
+ * @b64_data: contain the encoded data
+ * @result: the place where decoded data will be copied
+ * @result_size: holds the size of the result
+ *
+ * This function will decode the given encoded data.
+ *
+ **/
+int gnutls_b64_decode( const gnutls_datum *b64_data, char* result, int* result_size) {
+opaque* ret;
+int size;
+
+ size = _gnutls_fbase64_decode( pem_data->data, pem_data->size, &ret);
+ if (size < 0)
+ return size;
+
+ if (result==NULL || *result_size < size) {
+ gnutls_free(ret);
+ *result_size = size;
+ return GNUTLS_E_INVALID_REQUEST;
+ } else {
+ memcpy( result, ret, size);
+ gnutls_free(ret);
+ *result_size = size;
+ }
+
+ return 0;
+}
+
/* decodes data and puts the result into result (localy alocated)
* The result_size is the return value
*/