PokerUnicorn
Loading...
Searching...
No Matches
Cryptography

RSA encryption, decryption, signing and verification things. More...

Data Structures

struct  pkrsrv_rsa_key_t
 
struct  pkrsrv_rsa_keypair_t
 
struct  pkrsrv_rsa_encrypted_t
 

Macros

#define PKRSRV_RSA_PUB_EXPONENT   65537
 
#define PKRSRV_RSA_PRIME_BITS   2048
 
#define PKRSRV_RSA_PRIME_REPS   50
 
#define PKRSRV_RSA_BLOCK_SIZE   128
 
#define PKRSRV_MPZ_ENDIAN   1
 
#define PKRSRV_MPZ_ORDER   1
 
#define PKRSRV_RSA_RANDOM_SEED_ADDS_MASK   20
 

Typedefs

typedef uint8_t pkrsrv_rsa_random_seed_adds_t
 

Functions

uint32_t pkrsrv_rsa_hash_h32 (char *str)
 
uint32_t pkrsrv_rsa_hash_h32__n (char *data, ssize_t length)
 
bool pkrsrv_rsa_random_seed (unsigned char *seed, size_t size)
 
void pkrsrv_rsa_random_prime (mpz_t num)
 
pkrsrv_rsa_key_t * pkrsrv_rsa_key_new ()
 
void pkrsrv_rsa_key_free (pkrsrv_rsa_key_t *key)
 
pkrsrv_rsa_keypair_t * pkrsrv_rsa_keypair_new ()
 
void pkrsrv_rsa_keypair_free (pkrsrv_rsa_keypair_t *keypair)
 
pkrsrv_rsa_encrypted_t * pkrsrv_rsa_encrypted_new ()
 
void pkrsrv_rsa_encrypted_set_key (pkrsrv_rsa_encrypted_t *encrypted, pkrsrv_rsa_key_t *key)
 
void pkrsrv_rsa_encrypted_set_data (pkrsrv_rsa_encrypted_t *encrypted, pkrsrv_string_t *data)
 
void pkrsrv_rsa_encrypted_free (pkrsrv_rsa_encrypted_t *encrypted)
 
pkrsrv_rsa_encrypted_t * pkrsrv_rsa_encrypt (pkrsrv_string_t *data, pkrsrv_rsa_key_t *pubkey)
 
pkrsrv_string_t * pkrsrv_rsa_decrypt (pkrsrv_rsa_encrypted_t *encrypted, pkrsrv_rsa_key_t *privkey)
 
pkrsrv_string_t * pkrsrv_rsa_key_to_bin (pkrsrv_rsa_key_t *key)
 
pkrsrv_rsa_key_t * pkrsrv_rsa_key_from_bin (pkrsrv_string_t *hex)
 
pkrsrv_string_t * pkrsrv_rsa_key_to_hex (pkrsrv_rsa_key_t *key)
 
pkrsrv_rsa_key_t * pkrsrv_rsa_key_from_hex (pkrsrv_string_t *hex)
 
pkrsrv_string_t * pkrsrv_rsa_sign (pkrsrv_string_t *data, pkrsrv_rsa_key_t *privkey)
 
bool pkrsrv_rsa_verify (pkrsrv_string_t *data, pkrsrv_string_t *signature, pkrsrv_rsa_key_t *pubkey)
 
pkrsrv_string_t * pkrsrv_rsa_signature_to_hex (pkrsrv_string_t *signature_bin)
 
pkrsrv_string_t * pkrsrv_rsa_signature_from_hex (pkrsrv_string_t *signature_hex)
 

Detailed Description

RSA encryption, decryption, signing and verification things.


Data Structure Documentation

◆ pkrsrv_rsa_key

struct pkrsrv_rsa_key

RSA key object

+ Inheritance diagram for pkrsrv_rsa_key_t:

Data Fields

pkrsrv_ref_counted_t ref_counted
 
mpz_t e
 
mpz_t n
 
- Data Fields inherited from pkrsrv_ref_counted_t
int count
 
pkrsrv_ref_free_f_t free_f
 
pthread_mutex_t mutex
 

Additional Inherited Members

- Public Member Functions inherited from pkrsrv_ref_counted_t
#define PKRSRV_REF_COUNTED_INIT(obj, free_f)    pkrsrv_ref_counted_init(&(obj->ref_counted), (pkrsrv_ref_free_f_t) free_f);
 Initializes a reference-counted object. Should be called in the constructor of the object after the dynamic allocation.
 
#define PKRSRV_REF_COUNTED_USE(obj)
 Increments the reference count of a reference-counted object.
 
#define PKRSRV_REF_COUNTED_LEAVE(obj)
 Decrements the reference count of a reference-counted object.
 
- Protected Member Functions inherited from pkrsrv_ref_counted_t
void pkrsrv_ref_counted_init (pkrsrv_ref_counted_t *ref_counted, pkrsrv_ref_free_f_t free_f)
 Initializes a reference-counted object. Should be called in the constructor of the object after the dynamic allocation.
 
void pkrsrv_ref_counted_use (pkrsrv_ref_counted_t *ref_counted)
 Increments the reference count of a reference-counted object.
 
void pkrsrv_ref_counted_leave (void **obj_vp, pkrsrv_ref_counted_t *ref_counted)
 Decrements the reference count of a reference-counted object.
 

Field Documentation

◆ ref_counted

pkrsrv_ref_counted_t pkrsrv_rsa_key_t::ref_counted

◆ e

mpz_t pkrsrv_rsa_key_t::e

◆ n

mpz_t pkrsrv_rsa_key_t::n

◆ pkrsrv_rsa_keypair

struct pkrsrv_rsa_keypair
+ Inheritance diagram for pkrsrv_rsa_keypair_t:

Data Fields

pkrsrv_ref_counted_t ref_counted
 
pkrsrv_rsa_key_t * pubkey
 
pkrsrv_rsa_key_t * privkey
 
- Data Fields inherited from pkrsrv_ref_counted_t
int count
 
pkrsrv_ref_free_f_t free_f
 
pthread_mutex_t mutex
 

Additional Inherited Members

- Public Member Functions inherited from pkrsrv_ref_counted_t
#define PKRSRV_REF_COUNTED_INIT(obj, free_f)    pkrsrv_ref_counted_init(&(obj->ref_counted), (pkrsrv_ref_free_f_t) free_f);
 Initializes a reference-counted object. Should be called in the constructor of the object after the dynamic allocation.
 
#define PKRSRV_REF_COUNTED_USE(obj)
 Increments the reference count of a reference-counted object.
 
#define PKRSRV_REF_COUNTED_LEAVE(obj)
 Decrements the reference count of a reference-counted object.
 
- Protected Member Functions inherited from pkrsrv_ref_counted_t
void pkrsrv_ref_counted_init (pkrsrv_ref_counted_t *ref_counted, pkrsrv_ref_free_f_t free_f)
 Initializes a reference-counted object. Should be called in the constructor of the object after the dynamic allocation.
 
void pkrsrv_ref_counted_use (pkrsrv_ref_counted_t *ref_counted)
 Increments the reference count of a reference-counted object.
 
void pkrsrv_ref_counted_leave (void **obj_vp, pkrsrv_ref_counted_t *ref_counted)
 Decrements the reference count of a reference-counted object.
 

Field Documentation

◆ ref_counted

pkrsrv_ref_counted_t pkrsrv_rsa_keypair_t::ref_counted

◆ pubkey

pkrsrv_rsa_key_t* pkrsrv_rsa_keypair_t::pubkey

◆ privkey

pkrsrv_rsa_key_t* pkrsrv_rsa_keypair_t::privkey

◆ pkrsrv_rsa_encrypted

struct pkrsrv_rsa_encrypted
+ Inheritance diagram for pkrsrv_rsa_encrypted_t:

Data Fields

pkrsrv_ref_counted_t ref_counted
 
pkrsrv_string_t * data
 
pkrsrv_rsa_key_t * key
 
- Data Fields inherited from pkrsrv_ref_counted_t
int count
 
pkrsrv_ref_free_f_t free_f
 
pthread_mutex_t mutex
 

Additional Inherited Members

- Public Member Functions inherited from pkrsrv_ref_counted_t
#define PKRSRV_REF_COUNTED_INIT(obj, free_f)    pkrsrv_ref_counted_init(&(obj->ref_counted), (pkrsrv_ref_free_f_t) free_f);
 Initializes a reference-counted object. Should be called in the constructor of the object after the dynamic allocation.
 
#define PKRSRV_REF_COUNTED_USE(obj)
 Increments the reference count of a reference-counted object.
 
#define PKRSRV_REF_COUNTED_LEAVE(obj)
 Decrements the reference count of a reference-counted object.
 
- Protected Member Functions inherited from pkrsrv_ref_counted_t
void pkrsrv_ref_counted_init (pkrsrv_ref_counted_t *ref_counted, pkrsrv_ref_free_f_t free_f)
 Initializes a reference-counted object. Should be called in the constructor of the object after the dynamic allocation.
 
void pkrsrv_ref_counted_use (pkrsrv_ref_counted_t *ref_counted)
 Increments the reference count of a reference-counted object.
 
void pkrsrv_ref_counted_leave (void **obj_vp, pkrsrv_ref_counted_t *ref_counted)
 Decrements the reference count of a reference-counted object.
 

Field Documentation

◆ ref_counted

pkrsrv_ref_counted_t pkrsrv_rsa_encrypted_t::ref_counted

◆ data

pkrsrv_string_t* pkrsrv_rsa_encrypted_t::data

◆ key

pkrsrv_rsa_key_t* pkrsrv_rsa_encrypted_t::key

Macro Definition Documentation

◆ PKRSRV_RSA_PUB_EXPONENT

#define PKRSRV_RSA_PUB_EXPONENT   65537

◆ PKRSRV_RSA_PRIME_BITS

#define PKRSRV_RSA_PRIME_BITS   2048

◆ PKRSRV_RSA_PRIME_REPS

#define PKRSRV_RSA_PRIME_REPS   50

◆ PKRSRV_RSA_BLOCK_SIZE

#define PKRSRV_RSA_BLOCK_SIZE   128

◆ PKRSRV_MPZ_ENDIAN

#define PKRSRV_MPZ_ENDIAN   1

◆ PKRSRV_MPZ_ORDER

#define PKRSRV_MPZ_ORDER   1

◆ PKRSRV_RSA_RANDOM_SEED_ADDS_MASK

#define PKRSRV_RSA_RANDOM_SEED_ADDS_MASK   20

Typedef Documentation

◆ pkrsrv_rsa_random_seed_adds_t

Function Documentation

◆ pkrsrv_rsa_hash_h32()

uint32_t pkrsrv_rsa_hash_h32 ( char * str)

◆ pkrsrv_rsa_hash_h32__n()

uint32_t pkrsrv_rsa_hash_h32__n ( char * data,
ssize_t length )

◆ pkrsrv_rsa_random_seed()

bool pkrsrv_rsa_random_seed ( unsigned char * seed,
size_t size )

◆ pkrsrv_rsa_random_prime()

void pkrsrv_rsa_random_prime ( mpz_t num)

◆ pkrsrv_rsa_key_new()

pkrsrv_rsa_key_t * pkrsrv_rsa_key_new ( )

◆ pkrsrv_rsa_key_free()

void pkrsrv_rsa_key_free ( pkrsrv_rsa_key_t * key)

◆ pkrsrv_rsa_keypair_new()

pkrsrv_rsa_keypair_t * pkrsrv_rsa_keypair_new ( )

◆ pkrsrv_rsa_keypair_free()

void pkrsrv_rsa_keypair_free ( pkrsrv_rsa_keypair_t * keypair)

◆ pkrsrv_rsa_encrypted_new()

pkrsrv_rsa_encrypted_t * pkrsrv_rsa_encrypted_new ( )

◆ pkrsrv_rsa_encrypted_set_key()

void pkrsrv_rsa_encrypted_set_key ( pkrsrv_rsa_encrypted_t * encrypted,
pkrsrv_rsa_key_t * key )

◆ pkrsrv_rsa_encrypted_set_data()

void pkrsrv_rsa_encrypted_set_data ( pkrsrv_rsa_encrypted_t * encrypted,
pkrsrv_string_t * data )

◆ pkrsrv_rsa_encrypted_free()

void pkrsrv_rsa_encrypted_free ( pkrsrv_rsa_encrypted_t * encrypted)

◆ pkrsrv_rsa_encrypt()

pkrsrv_rsa_encrypted_t * pkrsrv_rsa_encrypt ( pkrsrv_string_t * data,
pkrsrv_rsa_key_t * pubkey )

◆ pkrsrv_rsa_decrypt()

pkrsrv_string_t * pkrsrv_rsa_decrypt ( pkrsrv_rsa_encrypted_t * encrypted,
pkrsrv_rsa_key_t * privkey )

◆ pkrsrv_rsa_key_to_bin()

pkrsrv_string_t * pkrsrv_rsa_key_to_bin ( pkrsrv_rsa_key_t * key)

◆ pkrsrv_rsa_key_from_bin()

pkrsrv_rsa_key_t * pkrsrv_rsa_key_from_bin ( pkrsrv_string_t * hex)

◆ pkrsrv_rsa_key_to_hex()

pkrsrv_string_t * pkrsrv_rsa_key_to_hex ( pkrsrv_rsa_key_t * key)

◆ pkrsrv_rsa_key_from_hex()

pkrsrv_rsa_key_t * pkrsrv_rsa_key_from_hex ( pkrsrv_string_t * hex)

◆ pkrsrv_rsa_sign()

pkrsrv_string_t * pkrsrv_rsa_sign ( pkrsrv_string_t * data,
pkrsrv_rsa_key_t * privkey )

◆ pkrsrv_rsa_verify()

bool pkrsrv_rsa_verify ( pkrsrv_string_t * data,
pkrsrv_string_t * signature,
pkrsrv_rsa_key_t * pubkey )

◆ pkrsrv_rsa_signature_to_hex()

pkrsrv_string_t * pkrsrv_rsa_signature_to_hex ( pkrsrv_string_t * signature_bin)

◆ pkrsrv_rsa_signature_from_hex()

pkrsrv_string_t * pkrsrv_rsa_signature_from_hex ( pkrsrv_string_t * signature_hex)