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_elg_encrypt( PKT_public_cert *pkc, PKT_pubkey_enc *enc, DEK *dek )
42
assert( is_ELGAMAL(enc->pubkey_algo) );
44
enc->d.elg.a = mpi_alloc( mpi_get_nlimbs(pkc->d.elg.p) );
45
enc->d.elg.b = mpi_alloc( mpi_get_nlimbs(pkc->d.elg.p) );
46
keyid_from_pkc( pkc, enc->keyid );
47
frame = encode_session_key( dek, mpi_get_nbits(pkc->d.elg.p) );
49
log_mpidump("Plain DEK frame: ", frame);
50
elg_encrypt( enc->d.elg.a, enc->d.elg.b, frame, &pkc->d.elg );
53
log_mpidump("Encry DEK a: ", enc->d.elg.a );
54
log_mpidump(" DEK b: ", enc->d.elg.b );
57
char *ustr = get_user_id_string( enc->keyid );
58
log_info("ElGamal encrypted for: %s\n", ustr );
65
g10_elg_sign( PKT_secret_cert *skc, PKT_signature *sig,
66
MD_HANDLE md, int digest_algo )
71
assert( is_ELGAMAL(sig->pubkey_algo) );
73
digest_algo = md_get_algo(md);
75
dp = md_read( md, digest_algo );
76
sig->digest_algo = digest_algo;
77
sig->digest_start[0] = dp[0];
78
sig->digest_start[1] = dp[1];
79
sig->d.elg.a = mpi_alloc( mpi_get_nlimbs(skc->d.elg.p) );
80
sig->d.elg.b = mpi_alloc( mpi_get_nlimbs(skc->d.elg.p) );
81
frame = encode_md_value( md, digest_algo, mpi_get_nbits(skc->d.elg.p));
83
log_mpidump("calc sig frame (elg): ", frame);
84
elg_sign( sig->d.elg.a, sig->d.elg.b, frame, &skc->d.elg );
87
char *ustr = get_user_id_string( sig->keyid );
88
log_info("ElGamal signature from: %s\n", ustr );