Import Upstream version 4.89
[hcoop/debian/exim4.git] / src / pdkim / rsa.h
CommitLineData
420a0d19 1/*
2813c06e 2 * PDKIM - a RFC4871 (DKIM) implementation
420a0d19 3 *
2813c06e 4 * Copyright (C) 2016 Exim maintainers
420a0d19 5 *
2813c06e 6 * RSA signing/verification interface
420a0d19 7 */
420a0d19 8
2813c06e 9#include "../exim.h"
420a0d19 10
2813c06e 11#ifndef DISABLE_DKIM /* entire file */
420a0d19 12
2813c06e 13#include "crypt_ver.h"
420a0d19 14
2813c06e
CE
15#ifdef RSA_OPENSSL
16# include <openssl/rsa.h>
17# include <openssl/ssl.h>
18# include <openssl/err.h>
19#elif defined(RSA_GNUTLS)
20# include <gnutls/gnutls.h>
21# include <gnutls/x509.h>
22# include <gnutls/abstract.h>
23#elif defined(RSA_GCRYPT)
24# include <gcrypt.h>
25# include <libtasn1.h>
420a0d19
CE
26#endif
27
2813c06e 28#include "../blob.h"
420a0d19 29
420a0d19 30
2813c06e 31#ifdef RSA_OPENSSL
420a0d19 32
2813c06e
CE
33typedef struct {
34 RSA * rsa;
35} es_ctx;
420a0d19 36
2813c06e
CE
37typedef struct {
38 RSA * rsa;
39} ev_ctx;
420a0d19 40
2813c06e 41#elif defined(RSA_GNUTLS)
420a0d19 42
2813c06e
CE
43typedef struct {
44 gnutls_x509_privkey_t rsa;
45} es_ctx;
420a0d19 46
2813c06e
CE
47typedef struct {
48 gnutls_pubkey_t rsa;
49} ev_ctx;
420a0d19 50
2813c06e 51#elif defined(RSA_GCRYPT)
420a0d19 52
2813c06e
CE
53typedef struct {
54 gcry_mpi_t n;
55 gcry_mpi_t e;
56 gcry_mpi_t d;
57 gcry_mpi_t p;
58 gcry_mpi_t q;
59 gcry_mpi_t dp;
60 gcry_mpi_t dq;
61 gcry_mpi_t qp;
62} es_ctx;
420a0d19 63
2813c06e
CE
64typedef struct {
65 gcry_mpi_t n;
66 gcry_mpi_t e;
67} ev_ctx;
420a0d19 68
2813c06e 69#endif
420a0d19
CE
70
71
2813c06e
CE
72extern void exim_rsa_init(void);
73extern blob * exim_rsa_data_append(blob *, int *, uschar *);
74
75extern const uschar * exim_rsa_signing_init(uschar *, es_ctx *);
76extern const uschar * exim_rsa_sign(es_ctx *, BOOL, blob *, blob *);
77extern const uschar * exim_rsa_verify_init(blob *, ev_ctx *);
78extern const uschar * exim_rsa_verify(ev_ctx *, BOOL, blob *, blob *);
420a0d19 79
2813c06e
CE
80#endif /*DISABLE_DKIM*/
81/* End of File */