Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / src / tls / tls_rsa.c
blobc0c89bb772e7e7e8488e4ad06e6b442a4dbdd037
1 /* $NetBSD$ */
3 /*++
4 /* NAME
5 /* tls_rsa
6 /* SUMMARY
7 /* RSA support
8 /* SYNOPSIS
9 /* #define TLS_INTERNAL
10 /* #include <tls.h>
12 /* RSA *tls_tmp_rsa_cb(ssl, export, keylength)
13 /* SSL *ssl; /* unused */
14 /* int export;
15 /* int keylength;
16 /* DESCRIPTION
17 /* This module maintains parameters for Diffie-Hellman key generation.
19 /* tls_tmp_rsa_cb() is a call-back routine for the
20 /* SSL_CTX_set_tmp_rsa_callback() function.
21 /* LICENSE
22 /* .ad
23 /* .fi
24 /* This software is free. You can do with it whatever you want.
25 /* The original author kindly requests that you acknowledge
26 /* the use of his software.
27 /* AUTHOR(S)
28 /* Originally written by:
29 /* Lutz Jaenicke
30 /* BTU Cottbus
31 /* Allgemeine Elektrotechnik
32 /* Universitaetsplatz 3-4
33 /* D-03044 Cottbus, Germany
35 /* Updated by:
36 /* Wietse Venema
37 /* IBM T.J. Watson Research
38 /* P.O. Box 704
39 /* Yorktown Heights, NY 10598, USA
40 /*--*/
42 /* System library. */
44 #include <sys_defs.h>
46 #ifdef USE_TLS
48 /* TLS library. */
50 #define TLS_INTERNAL
51 #include <tls.h>
53 /* tls_tmp_rsa_cb - call-back to generate ephemeral RSA key */
55 RSA *tls_tmp_rsa_cb(SSL *unused_ssl, int unused_export, int keylength)
57 static RSA *rsa_tmp;
59 /* Code adapted from OpenSSL apps/s_cb.c */
61 if (rsa_tmp == 0)
62 rsa_tmp = RSA_generate_key(keylength, RSA_F4, NULL, NULL);
63 return (rsa_tmp);
66 #ifdef TEST
68 int main(int unused_argc, char **unused_argv)
70 tls_tmp_rsa_cb(0, 1, 512);
71 tls_tmp_rsa_cb(0, 1, 1024);
72 tls_tmp_rsa_cb(0, 1, 2048);
73 tls_tmp_rsa_cb(0, 0, 512);
76 #endif
78 #endif