a5458bb8d2
All checks were successful
Latex Build / build-latex (Assignment 4 - Protokollsicherheit (Praxis)) (push) Successful in 1m1s
Latex Build / build-latex (Assignment 5 - Software Security - Teil 1) (push) Successful in 1m2s
Latex Build / build-latex (Assignment 6 - Software Security - Teil 2) (push) Successful in 1m0s
41 lines
No EOL
768 B
C
41 lines
No EOL
768 B
C
#ifndef RSA_H
|
|
#define RSA_H
|
|
|
|
#include <gmp.h>
|
|
#include <stdint.h>
|
|
|
|
#ifndef MODULUS_SIZE
|
|
#define MODULUS_SIZE 256ULL
|
|
#endif
|
|
|
|
typedef uint8_t u8;
|
|
typedef uint16_t u16;
|
|
typedef uint32_t u32;
|
|
typedef uint64_t u64;
|
|
|
|
typedef struct {
|
|
mpz_t p;
|
|
mpz_t q;
|
|
mpz_t n;
|
|
mpz_t e;
|
|
mpz_t d;
|
|
} rsa_key;
|
|
|
|
typedef struct {
|
|
mpz_t e;
|
|
mpz_t n;
|
|
} rsa_public_key;
|
|
|
|
void rsa_print(const rsa_key *key);
|
|
void rsa_public_print(const rsa_public_key *pk);
|
|
|
|
int rsa_init(rsa_key *key);
|
|
void rsa_free(rsa_key *key);
|
|
|
|
int rsa_public_init(rsa_public_key *key);
|
|
void rsa_public_free(rsa_public_key *key);
|
|
|
|
size_t rsa_sign(u8 *sig, const u8 *sha256, const rsa_key *key);
|
|
int rsa_verify(const u8 *sig, const size_t sig_length, const u8 *sha256, const rsa_public_key *pk);
|
|
|
|
#endif |