Documentation fix
Add relevant comments and explanations.
Fix indentation.
Add copyright notes.
diff --git a/library/ecdsa.c b/library/ecdsa.c
index 0f33b83..dba303b 100644
--- a/library/ecdsa.c
+++ b/library/ecdsa.c
@@ -289,9 +289,6 @@
/*
* Convert a signature to a raw concatenation of {r, s}
*/
-/*int mbedtls_ecdsa_signature_to_raw( const unsigned char *sig,
- size_t ssize, uint16_t byte_len,
- unsigned char *buf, size_t* slen )*/
int mbedtls_ecdsa_signature_to_raw( const unsigned char *sig,
size_t ssize, uint16_t byte_len,
unsigned char *buf, size_t bufsize,
@@ -305,7 +302,7 @@
if( 2 * byte_len > bufsize )
{
- return MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
+ return (MBEDTLS_ERR_ECP_BAD_INPUT_DATA);
}
mbedtls_mpi_init( &r );
@@ -326,29 +323,30 @@
}
if( ( ret = mbedtls_asn1_get_mpi( &p, end, &r ) ) != 0 ||
- ( ret = mbedtls_asn1_get_mpi( &p, end, &s ) ) != 0 )
+ ( ret = mbedtls_asn1_get_mpi( &p, end, &s ) ) != 0 )
{
ret += MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
goto cleanup;
}
p = (unsigned char *) buf;
- if( ( ret = mbedtls_mpi_write_binary(&r, p, byte_len) ) )
+ if( ( ret = mbedtls_mpi_write_binary( &r, p, byte_len) ) )
{
ret += MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
goto cleanup;
}
p += byte_len;
- if( ( ret = mbedtls_mpi_write_binary(&s, p, byte_len) ) )
+ if( ( ret = mbedtls_mpi_write_binary( &s, p, byte_len) ) )
{
ret += MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
goto cleanup;
}
*buflen = 2*byte_len;
- cleanup:
- mbedtls_mpi_free( &r );
- mbedtls_mpi_free( &s );
- return( ret );
+cleanup:
+ mbedtls_mpi_free( &r );
+ mbedtls_mpi_free( &s );
+
+ return( ret );
}
/*
diff --git a/library/pkcs11_client.c b/library/pkcs11_client.c
index 040b971..700587b 100644
--- a/library/pkcs11_client.c
+++ b/library/pkcs11_client.c
@@ -29,7 +29,6 @@
#include <stdint.h>
#include <string.h>
-#include <pkcs11.h>
#include "mbedtls/pkcs11_client.h"
@@ -144,7 +143,7 @@
CK_RV rv;
CK_MECHANISM mechanism = {0, NULL_PTR, 0};
CK_ULONG ck_sig_len;
-
+ (void)(md_alg);
/* This function takes size_t arguments but the underlying layer
takes unsigned long. Either type may be smaller than the other.
Legitimate values won't overflow either type but we still need
@@ -180,7 +179,8 @@
* each in the form of a big-endian byte sequence, with r and s
* having the same length as the base point.
*
- * A standard ECDSA signature is encoded in ASN.1:
+ * This library encodes ECDSA signatures in ASN.1 as documented
+ * for mbedtls_ecdsa_write_signature:
* SEQUENCE {
* r INTEGER,
* s INTEGER
@@ -315,7 +315,7 @@
static const mbedtls_pk_info_t mbedtls_pk_pkcs11_info =
MBEDTLS_PK_OPAQUE_INFO_1( "pkcs11"
, pkcs11_pk_get_bitlen
- , pkcs11_pk_can_do //can_do
+ , pkcs11_pk_can_do
, pkcs11_pk_signature_size
, pkcs11_verify
, pkcs11_sign