![]() |
PokerUnicorn
|
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) |
RSA encryption, decryption, signing and verification things.
struct pkrsrv_rsa_key |
RSA key object
Data Fields | |
pkrsrv_ref_counted_t | ref_counted |
mpz_t | e |
mpz_t | n |
![]() | |
int | count |
pkrsrv_ref_free_f_t | free_f |
pthread_mutex_t | mutex |
Additional Inherited Members | |
![]() | |
#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. | |
![]() | |
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. | |
pkrsrv_ref_counted_t pkrsrv_rsa_key_t::ref_counted |
mpz_t pkrsrv_rsa_key_t::e |
mpz_t pkrsrv_rsa_key_t::n |
struct pkrsrv_rsa_keypair |
Data Fields | |
pkrsrv_ref_counted_t | ref_counted |
pkrsrv_rsa_key_t * | pubkey |
pkrsrv_rsa_key_t * | privkey |
![]() | |
int | count |
pkrsrv_ref_free_f_t | free_f |
pthread_mutex_t | mutex |
Additional Inherited Members | |
![]() | |
#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. | |
![]() | |
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. | |
pkrsrv_ref_counted_t pkrsrv_rsa_keypair_t::ref_counted |
pkrsrv_rsa_key_t* pkrsrv_rsa_keypair_t::pubkey |
pkrsrv_rsa_key_t* pkrsrv_rsa_keypair_t::privkey |
struct pkrsrv_rsa_encrypted |
Data Fields | |
pkrsrv_ref_counted_t | ref_counted |
pkrsrv_string_t * | data |
pkrsrv_rsa_key_t * | key |
![]() | |
int | count |
pkrsrv_ref_free_f_t | free_f |
pthread_mutex_t | mutex |
Additional Inherited Members | |
![]() | |
#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. | |
![]() | |
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. | |
pkrsrv_ref_counted_t pkrsrv_rsa_encrypted_t::ref_counted |
pkrsrv_string_t* pkrsrv_rsa_encrypted_t::data |
pkrsrv_rsa_key_t* pkrsrv_rsa_encrypted_t::key |
#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 |
typedef uint8_t pkrsrv_rsa_random_seed_adds_t |
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 | ) |