1
/* rsa.c - glue code for RSA cipher
2
* Copyright (C) 1998 Free Software Foundation, Inc.
4
* This file is part of GNUPG.
6
* GNUPG is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* GNUPG is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
38
g10_rsa_encrypt( PKT_public_cert *pkc, PKT_pubkey_enc *enc, DEK *dek )
40
#ifdef HAVE_RSA_CIPHER
41
assert( is_RSA(enc->pubkey_algo) );
43
keyid_from_pkc( pkc, enc->keyid );
44
enc->d.rsa.rsa_integer = encode_session_key( dek,
45
mpi_get_nbits(pkc->d.rsa.rsa_n) );
47
log_mpidump("Plain DEK frame: ", enc->d.rsa.rsa_integer);
48
rsa_public( enc->d.rsa.rsa_integer, enc->d.rsa.rsa_integer, &pkc->d.rsa);
50
log_mpidump("Encry DEK frame: ", enc->d.rsa.rsa_integer);
52
char *ustr = get_user_id_string( enc->keyid );
53
log_info("RSA encrypted for: %s\n", ustr );
58
#endif/* ! HAVE_RSA_CIPHER*/
63
g10_rsa_sign( PKT_secret_cert *skc, PKT_signature *sig,
64
MD_HANDLE md, int digest_algo )
66
#ifdef HAVE_RSA_CIPHER
69
assert( is_RSA(sig->pubkey_algo) );
71
digest_algo = md_get_algo(md);
73
dp = md_read( md, digest_algo );
74
sig->digest_algo = digest_algo;
75
sig->digest_start[0] = dp[0];
76
sig->digest_start[1] = dp[1];
77
sig->d.rsa.rsa_integer =
78
encode_md_value( md, digest_algo, mpi_get_nbits(skc->d.rsa.rsa_n));
79
rsa_secret( sig->d.rsa.rsa_integer, sig->d.rsa.rsa_integer, &skc->d.rsa );
81
char *ustr = get_user_id_string( sig->keyid );
82
log_info("RSA signature from: %s\n", ustr );
87
#endif/* ! HAVE_RSA_CIPHER*/