Commit | Line | Data |
---|---|---|
2592e6c0 JH |
1 | /* |
2 | * PDKIM - a RFC4871 (DKIM) implementation | |
3 | * | |
4 | * Copyright (C) 2016 Exim maintainers | |
5 | * | |
6 | * RSA signing/verification interface | |
7 | */ | |
8 | ||
9 | #include "../exim.h" | |
10 | ||
11 | #ifndef DISABLE_DKIM /* entire file */ | |
12 | ||
13 | #include "crypt_ver.h" | |
14 | ||
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> | |
26 | #endif | |
27 | ||
63af6f3a | 28 | #include "../blob.h" |
2592e6c0 JH |
29 | |
30 | ||
31 | #ifdef RSA_OPENSSL | |
32 | ||
33 | typedef struct { | |
34 | RSA * rsa; | |
35 | } es_ctx; | |
36 | ||
37 | typedef struct { | |
38 | RSA * rsa; | |
39 | } ev_ctx; | |
40 | ||
41 | #elif defined(RSA_GNUTLS) | |
42 | ||
43 | typedef struct { | |
44 | gnutls_x509_privkey_t rsa; | |
45 | } es_ctx; | |
46 | ||
47 | typedef struct { | |
48 | gnutls_pubkey_t rsa; | |
49 | } ev_ctx; | |
50 | ||
51 | #elif defined(RSA_GCRYPT) | |
52 | ||
53 | typedef 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; | |
63 | ||
64 | typedef struct { | |
65 | gcry_mpi_t n; | |
66 | gcry_mpi_t e; | |
67 | } ev_ctx; | |
68 | ||
69 | #endif | |
70 | ||
71 | ||
72 | extern void exim_rsa_init(void); | |
73 | extern blob * exim_rsa_data_append(blob *, int *, uschar *); | |
74 | ||
75 | extern const uschar * exim_rsa_signing_init(uschar *, es_ctx *); | |
76 | extern const uschar * exim_rsa_sign(es_ctx *, BOOL, blob *, blob *); | |
77 | extern const uschar * exim_rsa_verify_init(blob *, ev_ctx *); | |
78 | extern const uschar * exim_rsa_verify(ev_ctx *, BOOL, blob *, blob *); | |
79 | ||
80 | #endif /*DISABLE_DKIM*/ | |
81 | /* End of File */ |