mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
changing {} style to match majority of previous style
This commit is contained in:
parent
da6cdf014b
commit
961d929f4d
320 changed files with 5502 additions and 10485 deletions
|
@ -49,8 +49,7 @@
|
|||
/*
|
||||
* Initialise a mbedtls_pk_context
|
||||
*/
|
||||
void mbedtls_pk_init(mbedtls_pk_context *ctx)
|
||||
{
|
||||
void mbedtls_pk_init(mbedtls_pk_context *ctx) {
|
||||
if (ctx == NULL)
|
||||
return;
|
||||
|
||||
|
@ -61,8 +60,7 @@ void mbedtls_pk_init(mbedtls_pk_context *ctx)
|
|||
/*
|
||||
* Free (the components of) a mbedtls_pk_context
|
||||
*/
|
||||
void mbedtls_pk_free(mbedtls_pk_context *ctx)
|
||||
{
|
||||
void mbedtls_pk_free(mbedtls_pk_context *ctx) {
|
||||
if (ctx == NULL || ctx->pk_info == NULL)
|
||||
return;
|
||||
|
||||
|
@ -74,8 +72,7 @@ void mbedtls_pk_free(mbedtls_pk_context *ctx)
|
|||
/*
|
||||
* Get pk_info structure from type
|
||||
*/
|
||||
const mbedtls_pk_info_t *mbedtls_pk_info_from_type(mbedtls_pk_type_t pk_type)
|
||||
{
|
||||
const mbedtls_pk_info_t *mbedtls_pk_info_from_type(mbedtls_pk_type_t pk_type) {
|
||||
switch (pk_type) {
|
||||
#if defined(MBEDTLS_RSA_C)
|
||||
case MBEDTLS_PK_RSA:
|
||||
|
@ -100,8 +97,7 @@ const mbedtls_pk_info_t *mbedtls_pk_info_from_type(mbedtls_pk_type_t pk_type)
|
|||
/*
|
||||
* Initialise context
|
||||
*/
|
||||
int mbedtls_pk_setup(mbedtls_pk_context *ctx, const mbedtls_pk_info_t *info)
|
||||
{
|
||||
int mbedtls_pk_setup(mbedtls_pk_context *ctx, const mbedtls_pk_info_t *info) {
|
||||
if (ctx == NULL || info == NULL || ctx->pk_info != NULL)
|
||||
return (MBEDTLS_ERR_PK_BAD_INPUT_DATA);
|
||||
|
||||
|
@ -120,8 +116,7 @@ int mbedtls_pk_setup(mbedtls_pk_context *ctx, const mbedtls_pk_info_t *info)
|
|||
int mbedtls_pk_setup_rsa_alt(mbedtls_pk_context *ctx, void *key,
|
||||
mbedtls_pk_rsa_alt_decrypt_func decrypt_func,
|
||||
mbedtls_pk_rsa_alt_sign_func sign_func,
|
||||
mbedtls_pk_rsa_alt_key_len_func key_len_func)
|
||||
{
|
||||
mbedtls_pk_rsa_alt_key_len_func key_len_func) {
|
||||
mbedtls_rsa_alt_context *rsa_alt;
|
||||
const mbedtls_pk_info_t *info = &mbedtls_rsa_alt_info;
|
||||
|
||||
|
@ -147,8 +142,7 @@ int mbedtls_pk_setup_rsa_alt(mbedtls_pk_context *ctx, void *key,
|
|||
/*
|
||||
* Tell if a PK can do the operations of the given type
|
||||
*/
|
||||
int mbedtls_pk_can_do(const mbedtls_pk_context *ctx, mbedtls_pk_type_t type)
|
||||
{
|
||||
int mbedtls_pk_can_do(const mbedtls_pk_context *ctx, mbedtls_pk_type_t type) {
|
||||
/* null or NONE context can't do anything */
|
||||
if (ctx == NULL || ctx->pk_info == NULL)
|
||||
return (0);
|
||||
|
@ -159,8 +153,7 @@ int mbedtls_pk_can_do(const mbedtls_pk_context *ctx, mbedtls_pk_type_t type)
|
|||
/*
|
||||
* Helper for mbedtls_pk_sign and mbedtls_pk_verify
|
||||
*/
|
||||
static inline int pk_hashlen_helper(mbedtls_md_type_t md_alg, size_t *hash_len)
|
||||
{
|
||||
static inline int pk_hashlen_helper(mbedtls_md_type_t md_alg, size_t *hash_len) {
|
||||
const mbedtls_md_info_t *md_info;
|
||||
|
||||
if (*hash_len != 0)
|
||||
|
@ -178,10 +171,9 @@ static inline int pk_hashlen_helper(mbedtls_md_type_t md_alg, size_t *hash_len)
|
|||
*/
|
||||
int mbedtls_pk_verify(mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg,
|
||||
const unsigned char *hash, size_t hash_len,
|
||||
const unsigned char *sig, size_t sig_len)
|
||||
{
|
||||
const unsigned char *sig, size_t sig_len) {
|
||||
if (ctx == NULL || ctx->pk_info == NULL ||
|
||||
pk_hashlen_helper(md_alg, &hash_len) != 0)
|
||||
pk_hashlen_helper(md_alg, &hash_len) != 0)
|
||||
return (MBEDTLS_ERR_PK_BAD_INPUT_DATA);
|
||||
|
||||
if (ctx->pk_info->verify_func == NULL)
|
||||
|
@ -197,8 +189,7 @@ int mbedtls_pk_verify(mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg,
|
|||
int mbedtls_pk_verify_ext(mbedtls_pk_type_t type, const void *options,
|
||||
mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg,
|
||||
const unsigned char *hash, size_t hash_len,
|
||||
const unsigned char *sig, size_t sig_len)
|
||||
{
|
||||
const unsigned char *sig, size_t sig_len) {
|
||||
if (ctx == NULL || ctx->pk_info == NULL)
|
||||
return (MBEDTLS_ERR_PK_BAD_INPUT_DATA);
|
||||
|
||||
|
@ -254,10 +245,9 @@ int mbedtls_pk_verify_ext(mbedtls_pk_type_t type, const void *options,
|
|||
int mbedtls_pk_sign(mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg,
|
||||
const unsigned char *hash, size_t hash_len,
|
||||
unsigned char *sig, size_t *sig_len,
|
||||
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng)
|
||||
{
|
||||
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng) {
|
||||
if (ctx == NULL || ctx->pk_info == NULL ||
|
||||
pk_hashlen_helper(md_alg, &hash_len) != 0)
|
||||
pk_hashlen_helper(md_alg, &hash_len) != 0)
|
||||
return (MBEDTLS_ERR_PK_BAD_INPUT_DATA);
|
||||
|
||||
if (ctx->pk_info->sign_func == NULL)
|
||||
|
@ -273,8 +263,7 @@ int mbedtls_pk_sign(mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg,
|
|||
int mbedtls_pk_decrypt(mbedtls_pk_context *ctx,
|
||||
const unsigned char *input, size_t ilen,
|
||||
unsigned char *output, size_t *olen, size_t osize,
|
||||
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng)
|
||||
{
|
||||
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng) {
|
||||
if (ctx == NULL || ctx->pk_info == NULL)
|
||||
return (MBEDTLS_ERR_PK_BAD_INPUT_DATA);
|
||||
|
||||
|
@ -291,8 +280,7 @@ int mbedtls_pk_decrypt(mbedtls_pk_context *ctx,
|
|||
int mbedtls_pk_encrypt(mbedtls_pk_context *ctx,
|
||||
const unsigned char *input, size_t ilen,
|
||||
unsigned char *output, size_t *olen, size_t osize,
|
||||
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng)
|
||||
{
|
||||
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng) {
|
||||
if (ctx == NULL || ctx->pk_info == NULL)
|
||||
return (MBEDTLS_ERR_PK_BAD_INPUT_DATA);
|
||||
|
||||
|
@ -306,11 +294,10 @@ int mbedtls_pk_encrypt(mbedtls_pk_context *ctx,
|
|||
/*
|
||||
* Check public-private key pair
|
||||
*/
|
||||
int mbedtls_pk_check_pair(const mbedtls_pk_context *pub, const mbedtls_pk_context *prv)
|
||||
{
|
||||
int mbedtls_pk_check_pair(const mbedtls_pk_context *pub, const mbedtls_pk_context *prv) {
|
||||
if (pub == NULL || pub->pk_info == NULL ||
|
||||
prv == NULL || prv->pk_info == NULL ||
|
||||
prv->pk_info->check_pair_func == NULL) {
|
||||
prv == NULL || prv->pk_info == NULL ||
|
||||
prv->pk_info->check_pair_func == NULL) {
|
||||
return (MBEDTLS_ERR_PK_BAD_INPUT_DATA);
|
||||
}
|
||||
|
||||
|
@ -328,8 +315,7 @@ int mbedtls_pk_check_pair(const mbedtls_pk_context *pub, const mbedtls_pk_contex
|
|||
/*
|
||||
* Get key size in bits
|
||||
*/
|
||||
size_t mbedtls_pk_get_bitlen(const mbedtls_pk_context *ctx)
|
||||
{
|
||||
size_t mbedtls_pk_get_bitlen(const mbedtls_pk_context *ctx) {
|
||||
if (ctx == NULL || ctx->pk_info == NULL)
|
||||
return (0);
|
||||
|
||||
|
@ -339,8 +325,7 @@ size_t mbedtls_pk_get_bitlen(const mbedtls_pk_context *ctx)
|
|||
/*
|
||||
* Export debug information
|
||||
*/
|
||||
int mbedtls_pk_debug(const mbedtls_pk_context *ctx, mbedtls_pk_debug_item *items)
|
||||
{
|
||||
int mbedtls_pk_debug(const mbedtls_pk_context *ctx, mbedtls_pk_debug_item *items) {
|
||||
if (ctx == NULL || ctx->pk_info == NULL)
|
||||
return (MBEDTLS_ERR_PK_BAD_INPUT_DATA);
|
||||
|
||||
|
@ -354,8 +339,7 @@ int mbedtls_pk_debug(const mbedtls_pk_context *ctx, mbedtls_pk_debug_item *items
|
|||
/*
|
||||
* Access the PK type name
|
||||
*/
|
||||
const char *mbedtls_pk_get_name(const mbedtls_pk_context *ctx)
|
||||
{
|
||||
const char *mbedtls_pk_get_name(const mbedtls_pk_context *ctx) {
|
||||
if (ctx == NULL || ctx->pk_info == NULL)
|
||||
return ("invalid PK");
|
||||
|
||||
|
@ -365,8 +349,7 @@ const char *mbedtls_pk_get_name(const mbedtls_pk_context *ctx)
|
|||
/*
|
||||
* Access the PK type
|
||||
*/
|
||||
mbedtls_pk_type_t mbedtls_pk_get_type(const mbedtls_pk_context *ctx)
|
||||
{
|
||||
mbedtls_pk_type_t mbedtls_pk_get_type(const mbedtls_pk_context *ctx) {
|
||||
if (ctx == NULL || ctx->pk_info == NULL)
|
||||
return (MBEDTLS_PK_NONE);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue