ReactOS 0.4.17-dev-784-g3812a95
dsa.h File Reference
#include "config.h"
#include "bignum.h"
#include "md.h"
Include dependency graph for dsa.h:

Go to the source code of this file.

Classes

struct  mbedtls_dsa_context
 DSA context structure. More...
 

Macros

#define MBEDTLS_ERR_DSA_BAD_INPUT_DATA   -0x3180
 
#define MBEDTLS_ERR_DSA_INVALID_KEY   -0x3200
 
#define MBEDTLS_ERR_DSA_VERIFY_FAILED   -0x3280
 
#define MBEDTLS_ERR_DSA_ALLOC_FAILED   -0x3300
 
#define MBEDTLS_ERR_DSA_RANDOM_FAILED   -0x3380
 
#define MBEDTLS_ERR_DSA_FILE_IO_ERROR   -0x3400
 
#define MBEDTLS_ERR_DSA_SIG_LEN_MISMATCH   -0x3480
 
#define MBEDTLS_DSA_ASN_SIGNATURE_MAX_LEN   64
 
#define MBEDTLS_DSA_MAX_GROUP   64
 
#define MBEDTLS_DSA_MAX_MODULUS   1024
 

Typedefs

typedef struct mbedtls_dsa_context mbedtls_dsa_context
 DSA context structure.
 

Functions

void mbedtls_dsa_init (mbedtls_dsa_context *ctx)
 This function initializes a DSA context.
 
void mbedtls_dsa_free (mbedtls_dsa_context *ctx)
 This function frees a DSA context.
 
int mbedtls_dsa_set_group (mbedtls_dsa_context *ctx, const mbedtls_mpi *P, const mbedtls_mpi *Q, const mbedtls_mpi *G)
 This function sets the DSA group parameters.
 
int mbedtls_dsa_genkey (mbedtls_dsa_context *ctx, size_t group_size, size_t modulus_size, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
 This function generates a DSA keypair.
 
int mbedtls_dsa_check_pqg (const mbedtls_mpi *P, const mbedtls_mpi *Q, const mbedtls_mpi *G)
 This function checks if the DSA group parameters are valid.
 
int mbedtls_dsa_check_pubkey (const mbedtls_dsa_context *ctx)
 This function checks if the public key is valid.
 
int mbedtls_dsa_check_privkey (const mbedtls_dsa_context *ctx)
 This function checks if the private key is valid.
 
int mbedtls_dsa_pubkey_from_privkey (mbedtls_dsa_context *ctx)
 This function derived public key from private key.
 
int mbedtls_dsa_sign (mbedtls_dsa_context *ctx, const unsigned char *hash, size_t hlen, unsigned char *sig, size_t *slen, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
 This function computes the DSA signature of a message hash.
 
int mbedtls_dsa_verify (mbedtls_dsa_context *ctx, const unsigned char *hash, size_t hlen, const unsigned char *sig, size_t slen)
 This function reads and verifies a DSA signature.
 

Macro Definition Documentation

◆ MBEDTLS_DSA_ASN_SIGNATURE_MAX_LEN

#define MBEDTLS_DSA_ASN_SIGNATURE_MAX_LEN   64

Definition at line 30 of file dsa.h.

◆ MBEDTLS_DSA_MAX_GROUP

#define MBEDTLS_DSA_MAX_GROUP   64

Definition at line 33 of file dsa.h.

◆ MBEDTLS_DSA_MAX_MODULUS

#define MBEDTLS_DSA_MAX_MODULUS   1024

Definition at line 36 of file dsa.h.

◆ MBEDTLS_ERR_DSA_ALLOC_FAILED

#define MBEDTLS_ERR_DSA_ALLOC_FAILED   -0x3300

Memory allocation failed.

Definition at line 25 of file dsa.h.

◆ MBEDTLS_ERR_DSA_BAD_INPUT_DATA

#define MBEDTLS_ERR_DSA_BAD_INPUT_DATA   -0x3180

Bad input parameters to function.

Definition at line 22 of file dsa.h.

◆ MBEDTLS_ERR_DSA_FILE_IO_ERROR

#define MBEDTLS_ERR_DSA_FILE_IO_ERROR   -0x3400

Read/write of file failed.

Definition at line 27 of file dsa.h.

◆ MBEDTLS_ERR_DSA_INVALID_KEY

#define MBEDTLS_ERR_DSA_INVALID_KEY   -0x3200

The private key is not valid.

Definition at line 23 of file dsa.h.

◆ MBEDTLS_ERR_DSA_RANDOM_FAILED

#define MBEDTLS_ERR_DSA_RANDOM_FAILED   -0x3380

Generation of random value, such as k, failed.

Definition at line 26 of file dsa.h.

◆ MBEDTLS_ERR_DSA_SIG_LEN_MISMATCH

#define MBEDTLS_ERR_DSA_SIG_LEN_MISMATCH   -0x3480

The signature is valid but its length is not matches to the given length.

Definition at line 28 of file dsa.h.

◆ MBEDTLS_ERR_DSA_VERIFY_FAILED

#define MBEDTLS_ERR_DSA_VERIFY_FAILED   -0x3280

The signature is not valid.

Definition at line 24 of file dsa.h.

Typedef Documentation

◆ mbedtls_dsa_context

DSA context structure.

Function Documentation

◆ mbedtls_dsa_check_pqg()

int mbedtls_dsa_check_pqg ( const mbedtls_mpi P,
const mbedtls_mpi Q,
const mbedtls_mpi G 
)

This function checks if the DSA group parameters are valid.

Parameters
PThe prime modulus P.
QThe prime sub-modulus Q.
GThe generator G.
Returns
0 if successful, or a specific error code.

◆ mbedtls_dsa_check_privkey()

int mbedtls_dsa_check_privkey ( const mbedtls_dsa_context ctx)

This function checks if the private key is valid.

Parameters
ctxThe DSA context.
Returns
0 if successful, or a specific error code.

◆ mbedtls_dsa_check_pubkey()

int mbedtls_dsa_check_pubkey ( const mbedtls_dsa_context ctx)

This function checks if the public key is valid.

Parameters
ctxThe DSA context.
Returns
0 if successful, or a specific error code.

◆ mbedtls_dsa_free()

void mbedtls_dsa_free ( mbedtls_dsa_context ctx)

This function frees a DSA context.

Parameters
ctxThe DSA context to free.

◆ mbedtls_dsa_genkey()

int mbedtls_dsa_genkey ( mbedtls_dsa_context ctx,
size_t  group_size,
size_t  modulus_size,
int(*)(void *, unsigned char *, size_t f_rng,
void p_rng 
)

This function generates a DSA keypair.

Parameters
ctxThe DSA context to store the keypair in.
group_sizeThe group size for the keypair.
modulus_sizeThe modulus size for the keypair.
f_rngThe RNG function.
p_rngThe RNG context.
Returns
0 if successful, or a specific error code.

◆ mbedtls_dsa_init()

void mbedtls_dsa_init ( mbedtls_dsa_context ctx)

This function initializes a DSA context.

Parameters
ctxThe DSA context to initialize.

◆ mbedtls_dsa_pubkey_from_privkey()

int mbedtls_dsa_pubkey_from_privkey ( mbedtls_dsa_context ctx)

This function derived public key from private key.

Parameters
ctxThe DSA context.
Returns
0 if successful, or a specific error code.

◆ mbedtls_dsa_set_group()

int mbedtls_dsa_set_group ( mbedtls_dsa_context ctx,
const mbedtls_mpi P,
const mbedtls_mpi Q,
const mbedtls_mpi G 
)

This function sets the DSA group parameters.

Parameters
ctxThe DSA context to store the parameters in.
PThe prime modulus P.
QThe prime sub-modulus Q.
GThe generator G.
Returns
0 if successful, or a specific error code.

◆ mbedtls_dsa_sign()

int mbedtls_dsa_sign ( mbedtls_dsa_context ctx,
const unsigned char hash,
size_t  hlen,
unsigned char sig,
size_t slen,
int(*)(void *, unsigned char *, size_t f_rng,
void p_rng 
)

This function computes the DSA signature of a message hash.

Parameters
ctxThe DSA context.
hashThe message hash.
hlenThe length of the hash.
sigThe buffer to write the signature to.
slenThe length of the signature written.
f_rngThe RNG function.
p_rngThe RNG context.
Returns
0 if successful, or a specific error code.

◆ mbedtls_dsa_verify()

int mbedtls_dsa_verify ( mbedtls_dsa_context ctx,
const unsigned char hash,
size_t  hlen,
const unsigned char sig,
size_t  slen 
)

This function reads and verifies a DSA signature.

Parameters
ctxThe DSA context.
hashThe message hash.
hlenThe length of the hash.
sigThe signature to read and verify.
slenThe length of the signature.
Returns
0 if successful, or a specific error code.