mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
add-key works
This commit is contained in:
parent
f9a7043782
commit
eed2faab53
8
AUTHORS
8
AUTHORS
@ -0,0 +1,8 @@
|
||||
Authors of GNU Privacy Guard (gnupg).
|
||||
|
||||
Werner Koch. Designed and implemented gnupg.
|
||||
|
||||
|
||||
TRANSLATIONS Marco d'Itri 1997-02-22
|
||||
Disclaim
|
||||
|
@ -1,3 +1,7 @@
|
||||
Mon May 25 19:10:59 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* rand-unix.c (fast_random_poll): fixed syntax bug.
|
||||
|
||||
Mon May 11 10:21:31 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* configure.in (PRINTABLE_OS_NAME): Linux is now GNU/Linux
|
||||
|
16
NEWS
16
NEWS
@ -1,3 +1,19 @@
|
||||
Noteworthy changes in version 0.2.19
|
||||
------------------------------------
|
||||
|
||||
* Replaced /dev/urandom in checks with new tool mk-tdata.
|
||||
|
||||
* Some assembler file cleanups; some more functions for the Alpha.
|
||||
|
||||
* Tiger has now the OpenPGP assigned number 6. Because the OID has
|
||||
changed, old signatures using this algorithm can't be verified.
|
||||
|
||||
* gnupg now encrypts the compressed packed and not any longer in the
|
||||
reverse order; anyway it can decrypt both versions. Thanks to Tom
|
||||
for telling me this (not security related) bug.
|
||||
|
||||
* --add-key works and you are now able to generate subkeys.
|
||||
|
||||
Noteworthy changes in version 0.2.18
|
||||
------------------------------------
|
||||
|
||||
|
3
TODO
3
TODO
@ -1,5 +1,6 @@
|
||||
|
||||
* make --add-key work (to add an ElGamal key to a DSA key).
|
||||
* add usage arguments to get_key_byname or return a PKC_LIST with
|
||||
all keys and add a selection.
|
||||
|
||||
* add readline support. Must enhance libreadline - Anyone?
|
||||
|
||||
|
6
checks/ChangeLog
Normal file
6
checks/ChangeLog
Normal file
@ -0,0 +1,6 @@
|
||||
Mon May 18 15:40:02 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* Makefile.am: Now uses mk-tdata to produce random test data.
|
||||
|
||||
* ChangeLog: New.
|
||||
|
@ -42,12 +42,12 @@ secring.skr: secring.skr.asc
|
||||
../g10/gpgm --yes --dearmor -o secring.skr secring.skr.asc
|
||||
|
||||
data-500:
|
||||
head -c 500 /dev/urandom >data-500
|
||||
../tools/mk-tdata 500 /dev/urandom >data-500
|
||||
data-9000:
|
||||
head -c 9000 /dev/urandom >data-9000
|
||||
../tools/mk-tdata 9000 /dev/urandom >data-9000
|
||||
data-32000:
|
||||
head -c 32000 /dev/urandom >data-32000
|
||||
../tools/mk-tdata 32000 /dev/urandom >data-32000
|
||||
data-80000:
|
||||
head -c 80000 /dev/urandom >data-80000
|
||||
../tools/mk-tdata 80000 /dev/urandom >data-80000
|
||||
|
||||
|
||||
|
@ -1,3 +1,11 @@
|
||||
Fri May 22 07:30:39 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* md.c (md_get_oid): Add a new one for TIGER.
|
||||
|
||||
Thu May 21 13:24:52 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* cipher.c: Add support for a dummy cipher
|
||||
|
||||
Thu May 14 15:40:36 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* rmd160.c (transform): fixed sigbus - I should better
|
||||
|
@ -46,10 +46,10 @@ static struct { const char *name; int algo; int keylen; } cipher_names[] = {
|
||||
{ "3DES", CIPHER_ALGO_3DES ,0 },
|
||||
{ "CAST", CIPHER_ALGO_CAST ,128 },
|
||||
{ "BLOWFISH160", CIPHER_ALGO_BLOWFISH160 ,160 },
|
||||
{ "ROT_N", CIPHER_ALGO_ROT_N ,0 },
|
||||
{ "SAFER_SK128", CIPHER_ALGO_SAFER_SK128 ,0 },
|
||||
{ "DES_SK", CIPHER_ALGO_DES_SK ,0 },
|
||||
{ "BLOWFISH", CIPHER_ALGO_BLOWFISH ,128 },
|
||||
{ "DUMMY" , CIPHER_ALGO_DUMMY ,128 },
|
||||
{NULL} };
|
||||
|
||||
|
||||
@ -76,6 +76,14 @@ struct cipher_handle_s {
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
dummy_setkey( void *c, byte *key, unsigned keylen ) { }
|
||||
static void
|
||||
dummy_encrypt_block( void *c, byte *outbuf, byte *inbuf ) { BUG(); }
|
||||
static void
|
||||
dummy_decrypt_block( void *c, byte *outbuf, byte *inbuf ) { BUG(); }
|
||||
|
||||
|
||||
/****************
|
||||
* Map a string to the cipher algo
|
||||
*/
|
||||
@ -115,6 +123,7 @@ check_cipher_algo( int algo )
|
||||
case CIPHER_ALGO_BLOWFISH160:
|
||||
case CIPHER_ALGO_BLOWFISH:
|
||||
case CIPHER_ALGO_CAST:
|
||||
case CIPHER_ALGO_DUMMY:
|
||||
return 0;
|
||||
default:
|
||||
return G10ERR_CIPHER_ALGO;
|
||||
@ -154,7 +163,9 @@ cipher_open( int algo, int mode, int secure )
|
||||
hd = secure ? m_alloc_secure_clear( sizeof *hd )
|
||||
: m_alloc_clear( sizeof *hd );
|
||||
hd->algo = algo;
|
||||
if( mode == CIPHER_MODE_AUTO_CFB ) {
|
||||
if( algo == CIPHER_ALGO_DUMMY )
|
||||
hd->mode = CIPHER_MODE_DUMMY;
|
||||
else if( mode == CIPHER_MODE_AUTO_CFB ) {
|
||||
if( algo != CIPHER_ALGO_BLOWFISH160 )
|
||||
hd->mode = CIPHER_MODE_PHILS_CFB;
|
||||
else
|
||||
@ -176,6 +187,12 @@ cipher_open( int algo, int mode, int secure )
|
||||
hd->decrypt = FNCCAST_CRYPT(cast5_decrypt_block);
|
||||
break;
|
||||
|
||||
case CIPHER_ALGO_DUMMY:
|
||||
hd->setkey = FNCCAST_SETKEY(dummy_setkey);
|
||||
hd->encrypt = FNCCAST_CRYPT(dummy_encrypt_block);
|
||||
hd->decrypt = FNCCAST_CRYPT(dummy_decrypt_block);
|
||||
break;
|
||||
|
||||
default: log_fatal("cipher_open: invalid algo %d\n", algo );
|
||||
}
|
||||
|
||||
@ -217,8 +234,8 @@ do_ecb_encrypt( CIPHER_HANDLE c, byte *outbuf, byte *inbuf, unsigned nblocks )
|
||||
|
||||
for(n=0; n < nblocks; n++ ) {
|
||||
(*c->encrypt)( &c->c.context, outbuf, inbuf );
|
||||
inbuf += CAST5_BLOCKSIZE;;
|
||||
outbuf += CAST5_BLOCKSIZE;
|
||||
inbuf += STD_BLOCKSIZE;;
|
||||
outbuf += STD_BLOCKSIZE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -229,8 +246,8 @@ do_ecb_decrypt( CIPHER_HANDLE c, byte *outbuf, byte *inbuf, unsigned nblocks )
|
||||
|
||||
for(n=0; n < nblocks; n++ ) {
|
||||
(*c->decrypt)( &c->c.context, outbuf, inbuf );
|
||||
inbuf += CAST5_BLOCKSIZE;;
|
||||
outbuf += CAST5_BLOCKSIZE;
|
||||
inbuf += STD_BLOCKSIZE;;
|
||||
outbuf += STD_BLOCKSIZE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -397,6 +414,10 @@ cipher_encrypt( CIPHER_HANDLE c, byte *outbuf, byte *inbuf, unsigned nbytes )
|
||||
case CIPHER_MODE_PHILS_CFB:
|
||||
do_cfb_encrypt(c, outbuf, inbuf, nbytes );
|
||||
break;
|
||||
case CIPHER_MODE_DUMMY:
|
||||
if( inbuf != outbuf )
|
||||
memmove( outbuf, inbuf, nbytes );
|
||||
break;
|
||||
default: log_fatal("cipher_encrypt: invalid mode %d\n", c->mode );
|
||||
}
|
||||
}
|
||||
@ -419,6 +440,10 @@ cipher_decrypt( CIPHER_HANDLE c, byte *outbuf, byte *inbuf, unsigned nbytes )
|
||||
case CIPHER_MODE_PHILS_CFB:
|
||||
do_cfb_decrypt(c, outbuf, inbuf, nbytes );
|
||||
break;
|
||||
case CIPHER_MODE_DUMMY:
|
||||
if( inbuf != outbuf )
|
||||
memmove( outbuf, inbuf, nbytes );
|
||||
break;
|
||||
default: log_fatal("cipher_decrypt: invalid mode %d\n", c->mode );
|
||||
}
|
||||
}
|
||||
@ -433,8 +458,8 @@ void
|
||||
cipher_sync( CIPHER_HANDLE c )
|
||||
{
|
||||
if( c->mode == CIPHER_MODE_PHILS_CFB && c->unused ) {
|
||||
memmove(c->iv + c->unused, c->iv, CAST5_BLOCKSIZE - c->unused );
|
||||
memcpy(c->iv, c->lastiv + CAST5_BLOCKSIZE - c->unused, c->unused);
|
||||
memmove(c->iv + c->unused, c->iv, STD_BLOCKSIZE - c->unused );
|
||||
memcpy(c->iv, c->lastiv + STD_BLOCKSIZE - c->unused, c->unused);
|
||||
c->unused = 0;
|
||||
}
|
||||
}
|
||||
|
33
cipher/md.c
33
cipher/md.c
@ -216,35 +216,48 @@ md_digest_length( int algo )
|
||||
}
|
||||
|
||||
|
||||
/* fixme: put the oids in a table and add a mode to enumerate the OIDs
|
||||
* to make g10/sig-check.c more portable */
|
||||
const byte *
|
||||
md_asn_oid( int algo, size_t *asnlen, size_t *mdlen )
|
||||
{
|
||||
size_t alen, mlen;
|
||||
size_t alen;
|
||||
byte *p;
|
||||
|
||||
if( algo == DIGEST_ALGO_MD5 ) {
|
||||
static byte asn[18] = /* Object ID is 1.2.840.113549.2.5 */
|
||||
{ 0x30, 0x20, 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86,0x48,
|
||||
0x86, 0xf7, 0x0d, 0x02, 0x05, 0x05, 0x00, 0x04, 0x10 };
|
||||
mlen = 16; alen = DIM(asn); p = asn;
|
||||
alen = DIM(asn); p = asn;
|
||||
}
|
||||
else if( algo == DIGEST_ALGO_RMD160 ) {
|
||||
static byte asn[15] = /* Object ID is 1.3.36.3.2.1 */
|
||||
{ 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x24, 0x03,
|
||||
0x02, 0x01, 0x05, 0x00, 0x04, 0x14 };
|
||||
mlen = 20; alen = DIM(asn); p = asn;
|
||||
alen = DIM(asn); p = asn;
|
||||
}
|
||||
else if( algo == DIGEST_ALGO_TIGER ) {
|
||||
static byte asn[15] = /* FIXME: Object ID is ???????????? */
|
||||
{ 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42,
|
||||
0x42, 0x42, 0x42, 0x42, 0x42, 0x42 };
|
||||
mlen = 24; alen = DIM(asn); p = asn;
|
||||
/* 40: SEQUENCE {
|
||||
* 12: SEQUENCE {
|
||||
* 8: OCTET STRING :54 49 47 45 52 31 39 32
|
||||
* 0: NULL
|
||||
* : }
|
||||
* 24: OCTET STRING
|
||||
* : }
|
||||
*
|
||||
* By replacing the 5th byte (0x04) with 0x16 we would have;
|
||||
* 8: IA5String 'TIGER192'
|
||||
*/
|
||||
static byte asn[18] =
|
||||
{ 0x30, 0x28, 0x30, 0x0c, 0x04, 0x08, 0x54, 0x49, 0x47,
|
||||
0x45, 0x52, 0x31, 0x39, 0x32, 0x05, 0x00, 0x04, 0x18 };
|
||||
alen = DIM(asn); p = asn;
|
||||
}
|
||||
else if( algo == DIGEST_ALGO_SHA1 ) {
|
||||
static byte asn[15] = /* Objet ID is 1.3.14.3.2.26 */
|
||||
static byte asn[15] = /* Object ID is 1.3.14.3.2.26 */
|
||||
{ 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03,
|
||||
0x02, 0x1a, 0x05, 0x00, 0x04, 0x14 };
|
||||
mlen = 20; alen = DIM(asn); p = asn;
|
||||
alen = DIM(asn); p = asn;
|
||||
}
|
||||
else
|
||||
log_bug("md_asn_oid(%d)", algo );
|
||||
@ -252,7 +265,7 @@ md_asn_oid( int algo, size_t *asnlen, size_t *mdlen )
|
||||
if( asnlen )
|
||||
*asnlen = alen;
|
||||
if( mdlen )
|
||||
*mdlen = mlen;
|
||||
*mdlen = p[alen-1];
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ fast_random_poll()
|
||||
{
|
||||
#if HAVE_GETHRTIME
|
||||
{ hrtime_t tv;
|
||||
tv = gethrtime(void);
|
||||
tv = gethrtime();
|
||||
add_randomness( &tv, sizeof(tv), 1 );
|
||||
}
|
||||
#elif HAVE_GETTIMEOFTIME
|
||||
|
27
doc/DETAILS
27
doc/DETAILS
@ -284,3 +284,30 @@ Status codes are:
|
||||
|
||||
|
||||
|
||||
Ich werde jetzt doch das HKP Protokoll implementieren:
|
||||
|
||||
Naja, die Doku ist so gut wie nichtexistent, da gebe ich Dir recht.
|
||||
In kurzen Worten:
|
||||
|
||||
(Minimal-)HTTP-Server auf Port 11371, versteht ein GET auf /pks/lookup,
|
||||
wobei die Query-Parameter (Key-Value-Paare mit = zwischen Key und
|
||||
Value; die Paare sind hinter ? und durch & getrennt). Gültige
|
||||
Operationen sind:
|
||||
|
||||
- - op (Operation) mit den Möglichkeiten index (gleich wie -kv bei
|
||||
PGP), vindex (-kvv) und get (-kxa)
|
||||
- - search: Liste der Worte, die im Key vorkommen müssen. Worte sind
|
||||
mit Worttrennzeichen wie Space, Punkt, @, ... getrennt, Worttrennzeichen
|
||||
werden nicht betrachtet, die Reihenfolge der Worte ist egal.
|
||||
- - exact: (on=aktiv, alles andere inaktiv) Nur die Schlüssel
|
||||
zurückgeben, die auch den "search"-String beinhalten (d.h.
|
||||
Wortreihenfolge und Sonderzeichen sind wichtig)
|
||||
- - fingerprint (Bei [v]index auch den Fingerprint ausgeben), "on"
|
||||
für aktiv, alles andere inaktiv
|
||||
|
||||
Neu (wird von GNUPG benutzt):
|
||||
/pks/lookup/<gnupg_formatierte_user_id>?op=<operation>
|
||||
|
||||
Zusätzlich versteht der Keyserver auch ein POST auf /pks/add, womit
|
||||
man Keys hochladen kann.
|
||||
|
||||
|
@ -1,3 +1,35 @@
|
||||
Tue May 26 11:24:33 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* passphrase.c (get_last_passphrase): New
|
||||
(set_next_passphrase): New.
|
||||
(passphrase_to_dek): add support for the above functions.
|
||||
* keyedit.c (make_keysig_packet): Add sigclass 0x18,
|
||||
changed all callers due to a new argument.
|
||||
* keygen.c (write_keybinding): New
|
||||
(generate_subkeypair): Add functionality
|
||||
(ask_algo, ask_keysize, ask_valid_days): Broke out of generate_keypair
|
||||
(ask_user_id, ask_passphrase): Ditto.
|
||||
|
||||
Thu May 21 11:26:13 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* g10.c,gpgd.c (main): Does now return an int, so that egcs does
|
||||
not complain.
|
||||
|
||||
* armor.c (fake_packet): Removed erro message and add a noticed
|
||||
that this part should be fixed.
|
||||
|
||||
* sign.c (sign_file): Compression now comes in front of encryption.
|
||||
* encode.c (encode_simple): Ditto.
|
||||
(encode_crypt): Ditto.
|
||||
|
||||
Tue May 19 16:18:19 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* armor.c (fake_packet): Changed assertion to log_error
|
||||
|
||||
Sat May 16 16:02:06 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* build-packet.c (build_packet): Add SUBKEY packets.
|
||||
|
||||
Fri May 15 17:57:23 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* sign.c (hash_for): New and used in all places here.
|
||||
|
@ -703,7 +703,12 @@ fake_packet( armor_filter_context_t *afx, IOBUF a,
|
||||
break;
|
||||
|
||||
case fhdrENDClearsig:
|
||||
assert( emplines );
|
||||
/* FIXME: this is wrong: Only the last CRLF should
|
||||
* not be included in the hash, muts rewrite the FSM again
|
||||
* This proble does only occur if the last line does not end
|
||||
* in with a LF?
|
||||
*/
|
||||
if( emplines )
|
||||
emplines--; /* don't count the last one */
|
||||
state = fhdrENDClearsigHelp;
|
||||
afx->helplen = n;
|
||||
|
@ -82,9 +82,11 @@ build_packet( IOBUF out, PACKET *pkt )
|
||||
case PKT_COMMENT:
|
||||
rc = do_comment( out, ctb, pkt->pkt.comment );
|
||||
break;
|
||||
case PKT_PUBKEY_SUBCERT:
|
||||
case PKT_PUBLIC_CERT:
|
||||
rc = do_public_cert( out, ctb, pkt->pkt.public_cert );
|
||||
break;
|
||||
case PKT_SECKEY_SUBCERT:
|
||||
case PKT_SECRET_CERT:
|
||||
rc = do_secret_cert( out, ctb, pkt->pkt.secret_cert );
|
||||
break;
|
||||
|
@ -75,6 +75,9 @@ do_compress( compress_filter_context_t *zfx, z_stream *zs, int flush, IOBUF a )
|
||||
do {
|
||||
zs->next_out = zfx->outbuf;
|
||||
zs->avail_out = zfx->outbufsize;
|
||||
if( DBG_FILTER )
|
||||
log_debug("call deflate: avail_in=%u, avail_out=%u\n",
|
||||
(unsigned)zs->avail_in, (unsigned)zs->avail_out);
|
||||
zrc = deflate( zs, flush );
|
||||
if( zrc == Z_STREAM_END && flush == Z_FINISH )
|
||||
;
|
||||
@ -145,6 +148,9 @@ do_uncompress( compress_filter_context_t *zfx, z_stream *zs,
|
||||
}
|
||||
zs->avail_in = n;
|
||||
}
|
||||
if( DBG_FILTER )
|
||||
log_debug("call inflate: avail_in=%u, avail_out=%u\n",
|
||||
(unsigned)zs->avail_in, (unsigned)zs->avail_out);
|
||||
zrc = inflate( zs, Z_PARTIAL_FLUSH );
|
||||
if( DBG_FILTER )
|
||||
log_debug("inflate returned: avail_in=%u, avail_out=%u, zrc=%d\n",
|
||||
|
20
g10/encode.c
20
g10/encode.c
@ -112,13 +112,10 @@ encode_simple( const char *filename, int mode )
|
||||
|
||||
if( opt.armor )
|
||||
iobuf_push_filter( out, armor_filter, &afx );
|
||||
|
||||
else
|
||||
write_comment( out, "#created by GNUPG v" VERSION " ("
|
||||
PRINTABLE_OS_NAME ")");
|
||||
|
||||
if( opt.compress )
|
||||
iobuf_push_filter( out, compress_filter, &zfx );
|
||||
|
||||
if( s2k ) {
|
||||
PKT_symkey_enc *enc = m_alloc_clear( sizeof *enc );
|
||||
enc->version = 4;
|
||||
@ -150,11 +147,14 @@ encode_simple( const char *filename, int mode )
|
||||
pt->buf = inp;
|
||||
pkt.pkttype = PKT_PLAINTEXT;
|
||||
pkt.pkt.plaintext = pt;
|
||||
cfx.datalen = filesize? calc_packet_length( &pkt ) : 0;
|
||||
cfx.datalen = filesize && !opt.compress ? calc_packet_length( &pkt ) : 0;
|
||||
|
||||
/* register the cipher filter */
|
||||
if( mode )
|
||||
iobuf_push_filter( out, cipher_filter, &cfx );
|
||||
/* register the compress filter */
|
||||
if( opt.compress )
|
||||
iobuf_push_filter( out, compress_filter, &zfx );
|
||||
|
||||
/* do the work */
|
||||
if( (rc = build_packet( out, &pkt )) )
|
||||
@ -211,13 +211,10 @@ encode_crypt( const char *filename, STRLIST remusr )
|
||||
|
||||
if( opt.armor )
|
||||
iobuf_push_filter( out, armor_filter, &afx );
|
||||
|
||||
else
|
||||
write_comment( out, "#created by GNUPG v" VERSION " ("
|
||||
PRINTABLE_OS_NAME ")");
|
||||
|
||||
if( opt.compress )
|
||||
iobuf_push_filter( out, compress_filter, &zfx );
|
||||
|
||||
/* create a session key */
|
||||
cfx.dek = m_alloc_secure( sizeof *cfx.dek );
|
||||
cfx.dek->algo = opt.def_cipher_algo;
|
||||
@ -249,10 +246,13 @@ encode_crypt( const char *filename, STRLIST remusr )
|
||||
init_packet(&pkt);
|
||||
pkt.pkttype = PKT_PLAINTEXT;
|
||||
pkt.pkt.plaintext = pt;
|
||||
cfx.datalen = filesize? calc_packet_length( &pkt ) : 0;
|
||||
cfx.datalen = filesize && !opt.compress? calc_packet_length( &pkt ) : 0;
|
||||
|
||||
/* register the cipher filter */
|
||||
iobuf_push_filter( out, cipher_filter, &cfx );
|
||||
/* register the compress filter */
|
||||
if( opt.compress )
|
||||
iobuf_push_filter( out, compress_filter, &zfx );
|
||||
|
||||
/* do the work */
|
||||
if( (rc = build_packet( out, &pkt )) )
|
||||
|
@ -201,7 +201,7 @@ strusage( int level )
|
||||
case 13: p = VERSION; break;
|
||||
case 17: p = PRINTABLE_OS_NAME; break;
|
||||
case 19: p =
|
||||
_("Please report bugs to <gnupg-bugs@isil.d.shuttle.de>.\n");
|
||||
_("Please report bugs to <gnupg-bugs@gnu.org>.\n");
|
||||
break;
|
||||
case 1:
|
||||
case 40: p =
|
||||
@ -364,7 +364,7 @@ check_opts(void)
|
||||
|
||||
|
||||
|
||||
void
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
ARGPARSE_ARGS pargs;
|
||||
@ -1005,6 +1005,7 @@ main( int argc, char **argv )
|
||||
FREE_STRLIST(remusr);
|
||||
FREE_STRLIST(locusr);
|
||||
g10_exit(0);
|
||||
return 8; /*NEVER REACHED*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -58,7 +58,7 @@ strusage( int level )
|
||||
case 13: p = VERSION; break;
|
||||
case 17: p = PRINTABLE_OS_NAME; break;
|
||||
case 19: p =
|
||||
"Please report bugs to <gnupg-bugs@isil.d.shuttle.de>.\n";
|
||||
"Please report bugs to <gnupg-bugs@gnu.org>.\n";
|
||||
break;
|
||||
case 1:
|
||||
case 40: p = "Usage: gpgd [options] (-h for help)";
|
||||
@ -135,7 +135,7 @@ set_debug(void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
ARGPARSE_ARGS pargs;
|
||||
@ -236,9 +236,8 @@ main( int argc, char **argv )
|
||||
become_daemon();
|
||||
|
||||
|
||||
|
||||
|
||||
g10_exit(0);
|
||||
return 8; /*NEVER REACHED*/
|
||||
}
|
||||
|
||||
|
||||
|
25
g10/import.c
25
g10/import.c
@ -43,7 +43,8 @@ static int chk_self_sigs( const char *fname, KBNODE keyblock,
|
||||
PKT_public_cert *pkc, u32 *keyid );
|
||||
static int delete_inv_parts( const char *fname, KBNODE keyblock, u32 *keyid );
|
||||
static int merge_blocks( const char *fname, KBNODE keyblock_orig,
|
||||
KBNODE keyblock, u32 *keyid, int *n_uids, int *n_sigs );
|
||||
KBNODE keyblock, u32 *keyid,
|
||||
int *n_uids, int *n_sigs, int *n_subk );
|
||||
static int append_uid( KBNODE keyblock, KBNODE node, int *n_sigs,
|
||||
const char *fname, u32 *keyid );
|
||||
static int merge_sigs( KBNODE dst, KBNODE src, int *n_sigs,
|
||||
@ -103,7 +104,7 @@ import_pubkeys( const char *fname )
|
||||
return G10ERR_OPEN_FILE;
|
||||
}
|
||||
|
||||
if( !opt.no_armor ) /* armored reading is not diabled */
|
||||
if( !opt.no_armor ) /* armored reading is not disabled */
|
||||
iobuf_push_filter( inp, armor_filter, &afx );
|
||||
|
||||
while( !(rc = read_block( inp, &cfx, &pending_pkt, &keyblock) )) {
|
||||
@ -305,7 +306,7 @@ import_one( const char *fname, KBNODE keyblock )
|
||||
log_info("%s: key %08lX imported\n", fname, (ulong)keyid[1]);
|
||||
}
|
||||
else { /* merge */
|
||||
int n_uids, n_sigs;
|
||||
int n_uids, n_sigs, n_subk;
|
||||
|
||||
/* Compare the original against the new key; just to be sure nothing
|
||||
* weird is going on */
|
||||
@ -335,12 +336,13 @@ import_one( const char *fname, KBNODE keyblock )
|
||||
/* and try to merge the block */
|
||||
clear_kbnode_flags( keyblock_orig );
|
||||
clear_kbnode_flags( keyblock );
|
||||
n_uids = n_sigs = 0;
|
||||
n_uids = n_sigs = n_subk = 0;
|
||||
rc = merge_blocks( fname, keyblock_orig, keyblock,
|
||||
keyid, &n_uids, &n_sigs );
|
||||
keyid, &n_uids, &n_sigs, &n_subk );
|
||||
if( rc )
|
||||
goto leave;
|
||||
if( n_uids || n_sigs ) { /* keyblock_orig has been updated; write */
|
||||
if( n_uids || n_sigs || n_subk ) {
|
||||
/* keyblock_orig has been updated; write */
|
||||
if( opt.verbose > 1 )
|
||||
log_info("%s: writing to '%s'\n",
|
||||
fname, keyblock_resource_name(&kbpos) );
|
||||
@ -364,6 +366,12 @@ import_one( const char *fname, KBNODE keyblock )
|
||||
else if( n_sigs )
|
||||
log_info("%s: key %08lX, %d new signatures\n",
|
||||
fname, (ulong)keyid[1], n_sigs );
|
||||
if( n_subk == 1 )
|
||||
log_info("%s: key %08lX, 1 new subkey\n",
|
||||
fname, (ulong)keyid[1]);
|
||||
else if( n_subk )
|
||||
log_info("%s: key %08lX, %d new subkeys\n",
|
||||
fname, (ulong)keyid[1], n_subk );
|
||||
}
|
||||
else
|
||||
log_info("%s: key %08lX, not changed\n", fname, (ulong)keyid[1] );
|
||||
@ -593,7 +601,7 @@ delete_inv_parts( const char *fname, KBNODE keyblock, u32 *keyid )
|
||||
*/
|
||||
static int
|
||||
merge_blocks( const char *fname, KBNODE keyblock_orig, KBNODE keyblock,
|
||||
u32 *keyid, int *n_uids, int *n_sigs )
|
||||
u32 *keyid, int *n_uids, int *n_sigs, int *n_subk )
|
||||
{
|
||||
KBNODE onode, node;
|
||||
int rc, found;
|
||||
@ -667,6 +675,9 @@ merge_blocks( const char *fname, KBNODE keyblock_orig, KBNODE keyblock,
|
||||
}
|
||||
}
|
||||
|
||||
/* 4th: add new subkeys */
|
||||
/* FIXME */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -98,6 +98,8 @@ int build_skc_list( STRLIST locusr, SKC_LIST *ret_skc_list,
|
||||
void set_passphrase_fd( int fd );
|
||||
int get_passphrase_fd(void);
|
||||
DEK *passphrase_to_dek( u32 *keyid, int cipher_algo, STRING2KEY *s2k, int mode);
|
||||
void set_next_passphrase( const char *s );
|
||||
char *get_last_passphrase(void);
|
||||
|
||||
/*-- getkey.c --*/
|
||||
void add_keyring( const char *name );
|
||||
|
@ -169,10 +169,6 @@ remove_keysigs( KBNODE keyblock, u32 *keyid, int all )
|
||||
&& (node->pkt->pkt.signature->sig_class&~3) == 0x10 ) {
|
||||
PKT_signature *sig = node->pkt->pkt.signature;
|
||||
|
||||
if( keyid[0] == sig->keyid[0] && keyid[1] == sig->keyid[1] ) {
|
||||
/* fixme: skip self-sig */
|
||||
}
|
||||
|
||||
tty_printf("\n \"%08lX %s ",
|
||||
sig->keyid[1], datestr_from_sig(sig));
|
||||
if( node->flag & 6 )
|
||||
@ -349,6 +345,7 @@ sign_key( const char *username, STRLIST locusr )
|
||||
|
||||
rc = make_keysig_packet( &sig, pkc,
|
||||
node->pkt->pkt.user_id,
|
||||
NULL,
|
||||
skc_rover->skc,
|
||||
0x10, 0 );
|
||||
if( rc ) {
|
||||
@ -568,9 +565,10 @@ change_passphrase( const char *username )
|
||||
KBNODE node;
|
||||
KBPOS kbpos;
|
||||
PKT_secret_cert *skc;
|
||||
u32 skc_keyid[2];
|
||||
u32 keyid[2];
|
||||
char *answer;
|
||||
int changed=0;
|
||||
char *passphrase = NULL;
|
||||
|
||||
/* find the userid */
|
||||
rc = find_secret_keyblock_byname( &kbpos, username );
|
||||
@ -595,18 +593,28 @@ change_passphrase( const char *username )
|
||||
}
|
||||
|
||||
skc = node->pkt->pkt.secret_cert;
|
||||
keyid_from_skc( skc, skc_keyid );
|
||||
keyid_from_skc( skc, keyid );
|
||||
tty_printf("sec %4u%c/%08lX %s ",
|
||||
nbits_from_skc( skc ),
|
||||
pubkey_letter( skc->pubkey_algo ),
|
||||
skc_keyid[1], datestr_from_skc(skc) );
|
||||
keyid[1], datestr_from_skc(skc) );
|
||||
{
|
||||
size_t n;
|
||||
char *p = get_user_id( skc_keyid, &n );
|
||||
char *p = get_user_id( keyid, &n );
|
||||
tty_print_string( p, n );
|
||||
m_free(p);
|
||||
tty_printf("\n");
|
||||
}
|
||||
for(node=keyblock; node; node = node->next ) {
|
||||
if( node->pkt->pkttype == PKT_SECKEY_SUBCERT ) {
|
||||
PKT_secret_cert *subskc = node->pkt->pkt.secret_cert;
|
||||
keyid_from_skc( subskc, keyid );
|
||||
tty_printf("sub %4u%c/%08lX %s\n",
|
||||
nbits_from_skc( subskc ),
|
||||
pubkey_letter( subskc->pubkey_algo ),
|
||||
keyid[1], datestr_from_skc(subskc) );
|
||||
}
|
||||
}
|
||||
|
||||
clear_kbnode_flags( keyblock );
|
||||
switch( is_secret_key_protected( skc ) ) {
|
||||
@ -619,10 +627,21 @@ change_passphrase( const char *username )
|
||||
default:
|
||||
tty_printf("Key is protected.\n");
|
||||
rc = check_secret_key( skc );
|
||||
if( !rc )
|
||||
passphrase = get_last_passphrase();
|
||||
break;
|
||||
}
|
||||
|
||||
/* fixme: unprotect all subkeys */
|
||||
/* unprotect all subkeys (use the supplied passphrase or ask)*/
|
||||
for(node=keyblock; node; node = node->next ) {
|
||||
if( node->pkt->pkttype == PKT_SECKEY_SUBCERT ) {
|
||||
PKT_secret_cert *subskc = node->pkt->pkt.secret_cert;
|
||||
set_next_passphrase( passphrase );
|
||||
rc = check_secret_key( subskc );
|
||||
if( rc )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( rc )
|
||||
tty_printf("Can't edit this key: %s\n", g10_errstr(rc));
|
||||
@ -632,6 +651,7 @@ change_passphrase( const char *username )
|
||||
|
||||
tty_printf(_("Enter the new passphrase for this secret key.\n\n") );
|
||||
|
||||
set_next_passphrase( NULL );
|
||||
for(;;) {
|
||||
s2k->mode = 1;
|
||||
s2k->hash_algo = DIGEST_ALGO_RMD160;
|
||||
@ -651,10 +671,17 @@ change_passphrase( const char *username )
|
||||
break;
|
||||
}
|
||||
else { /* okay */
|
||||
/* fixme: protect all subkeys too */
|
||||
skc->protect.algo = dek->algo;
|
||||
skc->protect.s2k = *s2k;
|
||||
rc = protect_secret_key( skc, dek );
|
||||
for(node=keyblock; !rc && node; node = node->next ) {
|
||||
if( node->pkt->pkttype == PKT_SECKEY_SUBCERT ) {
|
||||
PKT_secret_cert *subskc = node->pkt->pkt.secret_cert;
|
||||
subskc->protect.algo = dek->algo;
|
||||
subskc->protect.s2k = *s2k;
|
||||
rc = protect_secret_key( subskc, dek );
|
||||
}
|
||||
}
|
||||
if( rc )
|
||||
log_error("protect_secret_key failed: %s\n", g10_errstr(rc) );
|
||||
else
|
||||
@ -676,7 +703,9 @@ change_passphrase( const char *username )
|
||||
}
|
||||
|
||||
leave:
|
||||
m_free( passphrase );
|
||||
release_kbnode( keyblock );
|
||||
set_next_passphrase( NULL );
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -689,14 +718,16 @@ change_passphrase( const char *username )
|
||||
*/
|
||||
int
|
||||
make_keysig_packet( PKT_signature **ret_sig, PKT_public_cert *pkc,
|
||||
PKT_user_id *uid, PKT_secret_cert *skc,
|
||||
PKT_user_id *uid, PKT_public_cert *subpkc,
|
||||
PKT_secret_cert *skc,
|
||||
int sigclass, int digest_algo )
|
||||
{
|
||||
PKT_signature *sig;
|
||||
int rc=0;
|
||||
MD_HANDLE md;
|
||||
|
||||
assert( (sigclass >= 0x10 && sigclass <= 0x13) || sigclass == 0x20 );
|
||||
assert( (sigclass >= 0x10 && sigclass <= 0x13)
|
||||
|| sigclass == 0x20 || sigclass == 0x18 );
|
||||
if( !digest_algo ) {
|
||||
switch( skc->pubkey_algo ) {
|
||||
case PUBKEY_ALGO_DSA: digest_algo = DIGEST_ALGO_SHA1; break;
|
||||
@ -706,11 +737,13 @@ make_keysig_packet( PKT_signature **ret_sig, PKT_public_cert *pkc,
|
||||
}
|
||||
}
|
||||
md = md_open( digest_algo, 0 );
|
||||
/*md_start_debug( md, "make" );*/
|
||||
|
||||
/* hash the public key certificate and the user id */
|
||||
hash_public_cert( md, pkc );
|
||||
if( sigclass != 0x20 ) {
|
||||
if( sigclass == 0x18 ) { /* subkey binding */
|
||||
hash_public_cert( md, subpkc );
|
||||
}
|
||||
else if( sigclass != 0x20 ) {
|
||||
if( skc->version >=4 ) {
|
||||
byte buf[5];
|
||||
buf[0] = 0xb4; /* indicates a userid packet */
|
||||
@ -759,7 +792,7 @@ make_keysig_packet( PKT_signature **ret_sig, PKT_public_cert *pkc,
|
||||
/* add some magic */
|
||||
buf[0] = sig->version;
|
||||
buf[1] = 0xff;
|
||||
buf[2] = n >> 24; /* hmmm, n is only 16 bit, so tthis is always 0 */
|
||||
buf[2] = n >> 24; /* hmmm, n is only 16 bit, so this is always 0 */
|
||||
buf[3] = n >> 16;
|
||||
buf[4] = n >> 8;
|
||||
buf[5] = n;
|
||||
|
393
g10/keygen.c
393
g10/keygen.c
@ -79,7 +79,47 @@ write_selfsig( KBNODE root, KBNODE pub_root, PKT_secret_cert *skc )
|
||||
pkc = node->pkt->pkt.public_cert;
|
||||
|
||||
/* and make the signature */
|
||||
rc = make_keysig_packet( &sig, pkc, uid, skc, 0x13, 0 );
|
||||
rc = make_keysig_packet( &sig, pkc, uid, NULL, skc, 0x13, 0 );
|
||||
if( rc ) {
|
||||
log_error("make_keysig_packet failed: %s\n", g10_errstr(rc) );
|
||||
return rc;
|
||||
}
|
||||
|
||||
pkt = m_alloc_clear( sizeof *pkt );
|
||||
pkt->pkttype = PKT_SIGNATURE;
|
||||
pkt->pkt.signature = sig;
|
||||
add_kbnode( root, new_kbnode( pkt ) );
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int
|
||||
write_keybinding( KBNODE root, KBNODE pub_root, PKT_secret_cert *skc )
|
||||
{
|
||||
PACKET *pkt;
|
||||
PKT_signature *sig;
|
||||
int rc=0;
|
||||
KBNODE node;
|
||||
PKT_public_cert *pkc, *subpkc;
|
||||
|
||||
if( opt.verbose )
|
||||
log_info(_("writing key binding signature\n"));
|
||||
|
||||
/* get the pkc packet from the pub_tree */
|
||||
node = find_kbnode( pub_root, PKT_PUBLIC_CERT );
|
||||
if( !node )
|
||||
BUG();
|
||||
pkc = node->pkt->pkt.public_cert;
|
||||
/* find the last subkey */
|
||||
subpkc = NULL;
|
||||
for(node=pub_root; node; node = node->next ) {
|
||||
if( node->pkt->pkttype == PKT_PUBKEY_SUBCERT )
|
||||
subpkc = node->pkt->pkt.public_cert;
|
||||
}
|
||||
if( !subpkc )
|
||||
BUG();
|
||||
|
||||
/* and make the signature */
|
||||
rc = make_keysig_packet( &sig, pkc, NULL, subpkc, skc, 0x18, 0 );
|
||||
if( rc ) {
|
||||
log_error("make_keysig_packet failed: %s\n", g10_errstr(rc) );
|
||||
return rc;
|
||||
@ -95,7 +135,8 @@ write_selfsig( KBNODE root, KBNODE pub_root, PKT_secret_cert *skc )
|
||||
|
||||
static int
|
||||
gen_elg(unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
|
||||
STRING2KEY *s2k, PKT_secret_cert **ret_skc, u16 valid_days )
|
||||
STRING2KEY *s2k, PKT_secret_cert **ret_skc, u16 valid_days,
|
||||
int version )
|
||||
{
|
||||
int rc;
|
||||
int i;
|
||||
@ -111,6 +152,7 @@ gen_elg(unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
|
||||
skc = m_alloc_clear( sizeof *skc );
|
||||
pkc = m_alloc_clear( sizeof *pkc );
|
||||
skc->timestamp = pkc->timestamp = make_timestamp();
|
||||
skc->version = pkc->version = version;
|
||||
skc->valid_days = pkc->valid_days = valid_days;
|
||||
skc->pubkey_algo = pkc->pubkey_algo = PUBKEY_ALGO_ELGAMAL;
|
||||
pkc->d.elg.p = pk.p;
|
||||
@ -124,7 +166,7 @@ gen_elg(unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
|
||||
skc->protect.algo = 0;
|
||||
|
||||
skc->csum = checksum_mpi( skc->d.elg.x );
|
||||
/* return an unprotected version of the skc */
|
||||
if( ret_skc ) /* not a subkey: return an unprotected version of the skc */
|
||||
*ret_skc = copy_secret_cert( NULL, skc );
|
||||
|
||||
if( dek ) {
|
||||
@ -140,14 +182,14 @@ gen_elg(unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
|
||||
}
|
||||
|
||||
pkt = m_alloc_clear(sizeof *pkt);
|
||||
pkt->pkttype = PKT_PUBLIC_CERT;
|
||||
pkt->pkttype = ret_skc ? PKT_PUBLIC_CERT : PKT_PUBKEY_SUBCERT;
|
||||
pkt->pkt.public_cert = pkc;
|
||||
add_kbnode(pub_root, new_kbnode( pkt ));
|
||||
|
||||
/* don't know whether it makes sense to have the factors, so for now
|
||||
* we store them in the secret keyring (but they are not secret) */
|
||||
pkt = m_alloc_clear(sizeof *pkt);
|
||||
pkt->pkttype = PKT_SECRET_CERT;
|
||||
pkt->pkttype = ret_skc ? PKT_SECRET_CERT : PKT_SECKEY_SUBCERT;
|
||||
pkt->pkt.secret_cert = skc;
|
||||
add_kbnode(sec_root, new_kbnode( pkt ));
|
||||
for(i=0; factors[i]; i++ )
|
||||
@ -192,7 +234,7 @@ gen_rsa(unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
|
||||
skc->d.rsa.csum += checksum_mpi( skc->d.rsa.rsa_q );
|
||||
skc->d.rsa.csum += checksum_mpi( skc->d.rsa.rsa_u );
|
||||
|
||||
/* return an unprotected version of the skc */
|
||||
if( ret_skc ) /* not a subkey: return an unprotected version of the skc */
|
||||
*ret_skc = copy_secret_cert( NULL, skc );
|
||||
|
||||
if( dek ) {
|
||||
@ -210,12 +252,12 @@ gen_rsa(unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
|
||||
}
|
||||
|
||||
pkt = m_alloc_clear(sizeof *pkt);
|
||||
pkt->pkttype = PKT_PUBLIC_CERT;
|
||||
pkt->pkttype = ret_skc ? PKT_PUBLIC_CERT : PKT_PUBKEY_SUBCERT;
|
||||
pkt->pkt.public_cert = pkc;
|
||||
add_kbnode(pub_root, new_kbnode( pkt ));
|
||||
|
||||
pkt = m_alloc_clear(sizeof *pkt);
|
||||
pkt->pkttype = PKT_SECRET_CERT;
|
||||
pkt->pkttype = ret_skc ? PKT_SECRET_CERT : PKT_SECKEY_SUBCERT;
|
||||
pkt->pkt.secret_cert = skc;
|
||||
add_kbnode(sec_root, new_kbnode( pkt ));
|
||||
|
||||
@ -267,7 +309,7 @@ gen_dsa(unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
|
||||
skc->protect.algo = 0;
|
||||
|
||||
skc->csum = checksum_mpi( skc->d.dsa.x );
|
||||
/* return an unprotected version of the skc */
|
||||
if( ret_skc ) /* not a subkey: return an unprotected version of the skc */
|
||||
*ret_skc = copy_secret_cert( NULL, skc );
|
||||
|
||||
if( dek ) {
|
||||
@ -283,7 +325,7 @@ gen_dsa(unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
|
||||
}
|
||||
|
||||
pkt = m_alloc_clear(sizeof *pkt);
|
||||
pkt->pkttype = PKT_PUBLIC_CERT;
|
||||
pkt->pkttype = ret_skc ? PKT_PUBLIC_CERT : PKT_PUBKEY_SUBCERT;
|
||||
pkt->pkt.public_cert = pkc;
|
||||
add_kbnode(pub_root, new_kbnode( pkt ));
|
||||
|
||||
@ -294,7 +336,7 @@ gen_dsa(unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
|
||||
* are known.
|
||||
*/
|
||||
pkt = m_alloc_clear(sizeof *pkt);
|
||||
pkt->pkttype = PKT_SECRET_CERT;
|
||||
pkt->pkttype = ret_skc ? PKT_SECRET_CERT : PKT_SECKEY_SUBCERT;
|
||||
pkt->pkt.secret_cert = skc;
|
||||
add_kbnode(sec_root, new_kbnode( pkt ));
|
||||
for(i=1; factors[i]; i++ ) /* the first one is q */
|
||||
@ -334,74 +376,63 @@ check_valid_days( const char *s )
|
||||
}
|
||||
|
||||
|
||||
/****************
|
||||
* Generate a keypair
|
||||
*/
|
||||
void
|
||||
generate_keypair()
|
||||
static int
|
||||
ask_algo( int *ret_v4 )
|
||||
{
|
||||
char *answer;
|
||||
unsigned nbits;
|
||||
char *pub_fname = NULL;
|
||||
char *sec_fname = NULL;
|
||||
char *uid = NULL;
|
||||
KBNODE pub_root = NULL;
|
||||
KBNODE sec_root = NULL;
|
||||
PKT_secret_cert *skc = NULL;
|
||||
DEK *dek = NULL;
|
||||
STRING2KEY *s2k;
|
||||
int rc;
|
||||
int algo;
|
||||
const char *algo_name;
|
||||
char *aname, *acomment, *amail;
|
||||
int valid_days=0;
|
||||
|
||||
if( opt.batch || opt.answer_yes || opt.answer_no ) {
|
||||
log_error(_("Key generation can only be used in interactive mode\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
tty_printf(_("Please select the algorithm to use:\n"
|
||||
" (1) ElGamal is the suggested one.\n"
|
||||
" (2) DSA can only be used for signatures.\n"));
|
||||
" (2) ElGamal using v4 packets (OpenPGP)\n"
|
||||
" (3) DSA can only be used for signatures.\n"));
|
||||
#ifdef ENABLE_RSA_KEYGEN
|
||||
tty_printf(_(" (3) RSA cannot be used in the U.S.\n"));
|
||||
tty_printf(_(" (4) RSA cannot be used in the U.S.\n"));
|
||||
#endif
|
||||
|
||||
*ret_v4 = 0;
|
||||
for(;;) {
|
||||
#ifdef ENABLE_RSA_KEYGEN
|
||||
answer = tty_get(_("Your selection? (1,2,3) "));
|
||||
answer = tty_get(_("Your selection? (1,2,3,4) "));
|
||||
#else
|
||||
answer = tty_get(_("Your selection? (1,2) "));
|
||||
answer = tty_get(_("Your selection? (1,2,3) "));
|
||||
#endif
|
||||
tty_kill_prompt();
|
||||
algo = *answer? atoi(answer): 1;
|
||||
m_free(answer);
|
||||
if( algo == 1 ) {
|
||||
if( algo == 1 || algo == 2 ) {
|
||||
if( algo == 2 )
|
||||
*ret_v4 = 1;
|
||||
algo = PUBKEY_ALGO_ELGAMAL;
|
||||
algo_name = "ElGamal";
|
||||
break;
|
||||
}
|
||||
else if( algo == 2 ) {
|
||||
else if( algo == 3 ) {
|
||||
*ret_v4 = 1;
|
||||
algo = PUBKEY_ALGO_DSA;
|
||||
algo_name = "DSA";
|
||||
break;
|
||||
}
|
||||
#ifdef ENABLE_RSA_KEYGEN
|
||||
else if( algo == 3 ) {
|
||||
else if( algo == 4 ) {
|
||||
algo = PUBKEY_ALGO_RSA;
|
||||
algo_name = "RSA";
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return algo;
|
||||
}
|
||||
|
||||
|
||||
static unsigned
|
||||
ask_keysize( int algo )
|
||||
{
|
||||
char *answer;
|
||||
unsigned nbits;
|
||||
|
||||
tty_printf(_("About to generate a new %s keypair.\n"
|
||||
" minimum keysize is 768 bits\n"
|
||||
" default keysize is 1024 bits\n"
|
||||
" highest suggested keysize is 2048 bits\n"), algo_name );
|
||||
" highest suggested keysize is 2048 bits\n"),
|
||||
pubkey_algo_to_string(algo) );
|
||||
for(;;) {
|
||||
answer = tty_get(_("What keysize do you want? (1024) "));
|
||||
tty_kill_prompt();
|
||||
@ -446,6 +477,15 @@ generate_keypair()
|
||||
nbits = ((nbits + 31) / 32) * 32;
|
||||
tty_printf(_("rounded up to %u bits\n"), nbits );
|
||||
}
|
||||
return nbits;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
ask_valid_days()
|
||||
{
|
||||
char *answer;
|
||||
int valid_days=0;
|
||||
|
||||
tty_printf(_("Please specify how long the key should be valid.\n"
|
||||
" 0 = key does not expire\n"
|
||||
@ -491,15 +531,21 @@ generate_keypair()
|
||||
break;
|
||||
}
|
||||
m_free(answer);
|
||||
return valid_days;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
ask_user_id()
|
||||
{
|
||||
char *answer;
|
||||
char *aname, *acomment, *amail, *uid;
|
||||
|
||||
tty_printf( _("\n"
|
||||
"You need a User-ID to identify your key; the software constructs the user id\n"
|
||||
"from Real Name, Comment and Email Address in this form:\n"
|
||||
" \"Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>\"\n\n") );
|
||||
uid = NULL;
|
||||
aname=acomment=amail=NULL;
|
||||
uid = aname = acomment = amail = NULL;
|
||||
for(;;) {
|
||||
char *p;
|
||||
|
||||
@ -600,8 +646,16 @@ generate_keypair()
|
||||
break;
|
||||
m_free(uid); uid = NULL;
|
||||
}
|
||||
return uid;
|
||||
}
|
||||
|
||||
|
||||
static DEK *
|
||||
ask_passphrase( STRING2KEY **ret_s2k )
|
||||
{
|
||||
DEK *dek = NULL;
|
||||
STRING2KEY *s2k;
|
||||
|
||||
tty_printf(_("You need a Passphrase to protect your secret key.\n\n") );
|
||||
|
||||
s2k = m_alloc_secure( sizeof *s2k );
|
||||
@ -624,6 +678,77 @@ generate_keypair()
|
||||
else
|
||||
break; /* okay */
|
||||
}
|
||||
*ret_s2k = s2k;
|
||||
return dek;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
do_create( int algo, unsigned nbits, KBNODE pub_root, KBNODE sec_root,
|
||||
DEK *dek, STRING2KEY *s2k, PKT_secret_cert **skc, int valid_days,
|
||||
int v4_packet )
|
||||
{
|
||||
int rc=0;
|
||||
|
||||
tty_printf(_(
|
||||
"We need to generate a lot of random bytes. It is a good idea to perform\n"
|
||||
"some other action (work in another window, move the mouse, utilize the\n"
|
||||
"network and the disks) during the prime generation; this gives the random\n"
|
||||
"number generator a better chance to gain enough entropy.\n") );
|
||||
|
||||
if( algo == PUBKEY_ALGO_ELGAMAL )
|
||||
rc = gen_elg(nbits, pub_root, sec_root, dek, s2k,
|
||||
skc, valid_days, v4_packet? 4:3 );
|
||||
#ifdef ENABLE_RSA_KEYGEN
|
||||
else if( algo == PUBKEY_ALGO_RSA )
|
||||
rc = gen_rsa(nbits, pub_root, sec_root, dek, s2k, skc, valid_days );
|
||||
#endif
|
||||
else if( algo == PUBKEY_ALGO_DSA )
|
||||
rc = gen_dsa(nbits, pub_root, sec_root, dek, s2k, skc, valid_days);
|
||||
else
|
||||
BUG();
|
||||
if( !rc ) {
|
||||
add_kbnode( pub_root,
|
||||
make_comment_node("#created by GNUPG v" VERSION " ("
|
||||
PRINTABLE_OS_NAME ")"));
|
||||
add_kbnode( sec_root,
|
||||
make_comment_node("#created by GNUPG v" VERSION " ("
|
||||
PRINTABLE_OS_NAME ")"));
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/****************
|
||||
* Generate a keypair
|
||||
*/
|
||||
void
|
||||
generate_keypair()
|
||||
{
|
||||
unsigned nbits;
|
||||
char *pub_fname = NULL;
|
||||
char *sec_fname = NULL;
|
||||
char *uid = NULL;
|
||||
KBNODE pub_root = NULL;
|
||||
KBNODE sec_root = NULL;
|
||||
PKT_secret_cert *skc = NULL;
|
||||
DEK *dek;
|
||||
STRING2KEY *s2k;
|
||||
int rc;
|
||||
int algo;
|
||||
int ndays;
|
||||
int v4;
|
||||
|
||||
if( opt.batch || opt.answer_yes || opt.answer_no ) {
|
||||
log_error(_("Key generation can only be used in interactive mode\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
algo = ask_algo( &v4 );
|
||||
nbits = ask_keysize( algo );
|
||||
ndays = ask_valid_days();
|
||||
uid = ask_user_id();
|
||||
dek = ask_passphrase( &s2k );
|
||||
|
||||
|
||||
/* now check whether we are allowed to write to the keyrings */
|
||||
@ -642,30 +767,7 @@ generate_keypair()
|
||||
pub_root = make_comment_node("#"); delete_kbnode(pub_root);
|
||||
sec_root = make_comment_node("#"); delete_kbnode(sec_root);
|
||||
|
||||
tty_printf(_(
|
||||
"We need to generate a lot of random bytes. It is a good idea to perform\n"
|
||||
"some other action (work in another window, move the mouse, utilize the\n"
|
||||
"network and the disks) during the prime generation; this gives the random\n"
|
||||
"number generator a better chance to gain enough entropy.\n") );
|
||||
|
||||
if( algo == PUBKEY_ALGO_ELGAMAL )
|
||||
rc = gen_elg(nbits, pub_root, sec_root, dek, s2k, &skc, valid_days );
|
||||
#ifdef ENABLE_RSA_KEYGEN
|
||||
else if( algo == PUBKEY_ALGO_RSA )
|
||||
rc = gen_rsa(nbits, pub_root, sec_root, dek, s2k, &skc, valid_days );
|
||||
#endif
|
||||
else if( algo == PUBKEY_ALGO_DSA )
|
||||
rc = gen_dsa(nbits, pub_root, sec_root, dek, s2k, &skc, valid_days);
|
||||
else
|
||||
BUG();
|
||||
if( !rc ) {
|
||||
add_kbnode( pub_root,
|
||||
make_comment_node("#created by GNUPG v" VERSION " ("
|
||||
PRINTABLE_OS_NAME ")"));
|
||||
add_kbnode( sec_root,
|
||||
make_comment_node("#created by GNUPG v" VERSION " ("
|
||||
PRINTABLE_OS_NAME ")"));
|
||||
}
|
||||
rc = do_create( algo, nbits, pub_root, sec_root, dek, s2k, &skc, ndays, v4);
|
||||
if( !rc )
|
||||
write_uid(pub_root, uid );
|
||||
if( !rc )
|
||||
@ -718,6 +820,11 @@ generate_keypair()
|
||||
log_error("can't write secret key: %s\n", g10_errstr(rc) );
|
||||
else {
|
||||
tty_printf(_("public and secret key created and signed.\n") );
|
||||
if( algo == PUBKEY_ALGO_DSA )
|
||||
tty_printf(_("Note that this key cannot be used for "
|
||||
"encryption. You may want to use\n"
|
||||
"the command \"--add-key\" to generate a "
|
||||
"secondary key for this purpose.\n") );
|
||||
}
|
||||
|
||||
if( !rc1 )
|
||||
@ -745,8 +852,148 @@ generate_keypair()
|
||||
* add a new subkey to an existing key.
|
||||
*/
|
||||
void
|
||||
generate_subkeypair( const char *userid )
|
||||
generate_subkeypair( const char *username )
|
||||
{
|
||||
log_fatal("To be implemented :-)\n");
|
||||
int rc=0;
|
||||
KBPOS pub_kbpos, sec_kbpos;
|
||||
KBNODE pub_keyblock = NULL;
|
||||
KBNODE sec_keyblock = NULL;
|
||||
KBNODE node;
|
||||
PKT_secret_cert *skc = NULL; /* this is the primary skc */
|
||||
u32 keyid[2];
|
||||
int v4, algo, ndays;
|
||||
unsigned nbits;
|
||||
char *passphrase = NULL;
|
||||
DEK *dek = NULL;
|
||||
STRING2KEY *s2k = NULL;
|
||||
|
||||
if( opt.batch || opt.answer_yes || opt.answer_no ) {
|
||||
log_error(_("Key generation can only be used in interactive mode\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
/* search the userid */
|
||||
rc = find_secret_keyblock_byname( &sec_kbpos, username );
|
||||
if( rc ) {
|
||||
log_error("user '%s' not found\n", username );
|
||||
goto leave;
|
||||
}
|
||||
rc = read_keyblock( &sec_kbpos, &sec_keyblock );
|
||||
if( rc ) {
|
||||
log_error("error reading the secret key: %s\n", g10_errstr(rc) );
|
||||
goto leave;
|
||||
}
|
||||
/* and the public key */
|
||||
rc = find_keyblock_byname( &pub_kbpos, username );
|
||||
if( rc ) {
|
||||
log_error("user '%s' not found in public ring\n", username );
|
||||
goto leave;
|
||||
}
|
||||
rc = read_keyblock( &pub_kbpos, &pub_keyblock );
|
||||
if( rc ) {
|
||||
log_error("error reading the public key: %s\n", g10_errstr(rc) );
|
||||
goto leave;
|
||||
}
|
||||
|
||||
/* break out the primary key */
|
||||
node = find_kbnode( sec_keyblock, PKT_SECRET_CERT );
|
||||
if( !node ) {
|
||||
log_error("Oops; secret key not found anymore!\n");
|
||||
rc = G10ERR_GENERAL;
|
||||
goto leave;
|
||||
}
|
||||
|
||||
/* make a copy of the skc to keep the protected one in the keyblock */
|
||||
skc = copy_secret_cert( NULL, node->pkt->pkt.secret_cert );
|
||||
keyid_from_skc( skc, keyid );
|
||||
/* display primary and all secondary keys */
|
||||
tty_printf("sec %4u%c/%08lX %s ",
|
||||
nbits_from_skc( skc ),
|
||||
pubkey_letter( skc->pubkey_algo ),
|
||||
keyid[1], datestr_from_skc(skc) );
|
||||
{
|
||||
size_t n;
|
||||
char *p = get_user_id( keyid, &n );
|
||||
tty_print_string( p, n );
|
||||
m_free(p);
|
||||
tty_printf("\n");
|
||||
}
|
||||
for(node=sec_keyblock; node; node = node->next ) {
|
||||
if( node->pkt->pkttype == PKT_SECKEY_SUBCERT ) {
|
||||
PKT_secret_cert *subskc = node->pkt->pkt.secret_cert;
|
||||
keyid_from_skc( subskc, keyid );
|
||||
tty_printf("sub %4u%c/%08lX %s\n",
|
||||
nbits_from_skc( subskc ),
|
||||
pubkey_letter( subskc->pubkey_algo ),
|
||||
keyid[1], datestr_from_skc(subskc) );
|
||||
}
|
||||
}
|
||||
tty_printf("\n");
|
||||
|
||||
|
||||
|
||||
/* unprotect to get the passphrase */
|
||||
switch( is_secret_key_protected( skc ) ) {
|
||||
case -1:
|
||||
rc = G10ERR_PUBKEY_ALGO;
|
||||
break;
|
||||
case 0:
|
||||
tty_printf("This key is not protected.\n");
|
||||
break;
|
||||
default:
|
||||
tty_printf("Key is protected.\n");
|
||||
rc = check_secret_key( skc );
|
||||
if( !rc )
|
||||
passphrase = get_last_passphrase();
|
||||
break;
|
||||
}
|
||||
if( rc )
|
||||
goto leave;
|
||||
|
||||
|
||||
algo = ask_algo( &v4 );
|
||||
nbits = ask_keysize( algo );
|
||||
ndays = ask_valid_days();
|
||||
|
||||
if( passphrase ) {
|
||||
s2k = m_alloc_secure( sizeof *s2k );
|
||||
s2k->mode = 1;
|
||||
s2k->hash_algo = DIGEST_ALGO_RMD160;
|
||||
set_next_passphrase( passphrase );
|
||||
dek = passphrase_to_dek( NULL, CIPHER_ALGO_BLOWFISH, s2k, 2 );
|
||||
}
|
||||
|
||||
rc = do_create( algo, nbits, pub_keyblock, sec_keyblock,
|
||||
dek, s2k, NULL, ndays, v4 );
|
||||
if( !rc )
|
||||
rc = write_keybinding(pub_keyblock, pub_keyblock, skc);
|
||||
if( !rc )
|
||||
rc = write_keybinding(sec_keyblock, pub_keyblock, skc);
|
||||
/* write back */
|
||||
if( !rc ) {
|
||||
rc = update_keyblock( &pub_kbpos, pub_keyblock );
|
||||
if( rc )
|
||||
log_error("update_public_keyblock failed\n" );
|
||||
}
|
||||
if( !rc ) {
|
||||
rc = update_keyblock( &sec_kbpos, sec_keyblock );
|
||||
if( rc )
|
||||
log_error("update_secret_keyblock failed\n" );
|
||||
}
|
||||
if( !rc )
|
||||
tty_printf(_("public and secret subkey created.\n") );
|
||||
|
||||
|
||||
leave:
|
||||
if( rc )
|
||||
tty_printf(_("Key generation failed: %s\n"), g10_errstr(rc) );
|
||||
m_free( passphrase );
|
||||
m_free( dek );
|
||||
m_free( s2k );
|
||||
if( skc ) /* release the copy of the (now unprotected) secret key */
|
||||
free_secret_cert(skc);
|
||||
release_kbnode( sec_keyblock );
|
||||
release_kbnode( pub_keyblock );
|
||||
set_next_passphrase( NULL );
|
||||
}
|
||||
|
||||
|
246
g10/ks-proto.c
246
g10/ks-proto.c
@ -18,6 +18,32 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
/****************
|
||||
* The extended HKP protocol:
|
||||
*
|
||||
* GET /pks/lookup[/<gnupg_user_id>][?[op=<cmd>][&armor=0][&search=<keywords>]]
|
||||
*
|
||||
* Default is: "armor=1", "op=get". "search" is only allowed if gnupg_user_id
|
||||
* is not present. GET maybe replaced by HEAD in which case only some status
|
||||
* information is returned.
|
||||
*
|
||||
* Hmmm, I don't like it, the better solution is to use:
|
||||
*
|
||||
* /pks/gnupg/get for binary lookups
|
||||
* /pks/gnupg/upd to update a key
|
||||
* /pks/gnupg/ins to insert a new key
|
||||
*
|
||||
* Optional a version string can be inserted as in:
|
||||
*
|
||||
* /pks/gnupg/v1.0/get
|
||||
*
|
||||
* Returned HTTP options:
|
||||
* X-Key-Hash: <rmd160 hash value of the keyblock>
|
||||
* X-Key-MTime: <last modification time>
|
||||
* X-Key-LID: <local_key_id_used_for_update_etc>
|
||||
* [fixme: is X-.... allowed?]
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -34,6 +60,226 @@ read_line( FILE *fp )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/****************
|
||||
* Send a HKP request
|
||||
*/
|
||||
int
|
||||
hkp_request( int operation, const char *user_id )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/************************************************
|
||||
******* client communication stuff ************
|
||||
************************************************/
|
||||
|
||||
/****************
|
||||
* Initialisieren des clients
|
||||
* Es wird ein Handle zurückgegeben oder -1 bei einem fehler.
|
||||
* z.Z. ist nut eine Verbindung gleichzeitig möglich.
|
||||
* Wenn einer serverpid von 0 angegeben wird, so wird diese
|
||||
* der environment variabeln ATEXDB_PID entnommen.
|
||||
*/
|
||||
|
||||
int
|
||||
hkp_open( const char *serverurl )
|
||||
{
|
||||
const char *s;
|
||||
|
||||
s = SERVER_NAME_TEMPLATE;
|
||||
client.serv_name = xmalloc(strlen(s) + 10 );
|
||||
sprintf(client.serv_name,s, serverpid );
|
||||
if( opt.verbose )
|
||||
Info("Using unix domain stream '%s'", client.serv_name );
|
||||
|
||||
memset( &client.serv_addr, 0, sizeof client.serv_addr );
|
||||
client.serv_addr.sun_family = AF_UNIX;
|
||||
strcpy( client.serv_addr.sun_path, client.serv_name );
|
||||
client.serv_addr_len = strlen(client.serv_addr.sun_path)
|
||||
+ sizeof client.serv_addr.sun_family;
|
||||
|
||||
client.sockfd = -1;
|
||||
if( DoCheckVersion() )
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
DoConnect()
|
||||
{
|
||||
if( client.sockfd != -1 )
|
||||
DoDisconnect();
|
||||
if( (client.sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1 ) {
|
||||
Error(1000,"can't open unix domain socket");
|
||||
return 1;
|
||||
}
|
||||
if( connect(client.sockfd, (struct sockaddr*)&client.serv_addr,
|
||||
client.serv_addr_len) == -1 ) {
|
||||
Error(1000,"can't connect to '%s'",client.serv_addr.sun_path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0; /* okay */
|
||||
}
|
||||
|
||||
static int
|
||||
DoDisconnect()
|
||||
{
|
||||
if( client.sockfd != -1 ) {
|
||||
close(client.sockfd);
|
||||
client.sockfd = -1;
|
||||
}
|
||||
return 0; /* okay */
|
||||
}
|
||||
|
||||
/****************
|
||||
* NBYTES auf den aktuellen stream schreiben.
|
||||
*/
|
||||
static int
|
||||
DoWrite( void *buf, size_t nbytes )
|
||||
{
|
||||
size_t nleft = nbytes;
|
||||
ssize_t nwritten;
|
||||
|
||||
while( nleft > 0 ) {
|
||||
/* FIXME: add EINTR handling */
|
||||
nwritten = write(client.sockfd, buf, nleft);
|
||||
if( nwritten < 0 ) {
|
||||
Error(1000,"error writing to server");
|
||||
return -1;
|
||||
}
|
||||
nleft -= nwritten;
|
||||
buf = (char*)buf + nwritten;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
DoWriteStr( const char *s )
|
||||
{
|
||||
return DoWrite((char *)s, strlen(s) );
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
DoRead( void *buf, size_t buflen, size_t *ret_nread, int stop)
|
||||
{
|
||||
size_t nleft = buflen;
|
||||
int nread;
|
||||
char *p;
|
||||
|
||||
p = buf;
|
||||
while( nleft > 0 ) {
|
||||
/* FIXME: add EINTR handling */
|
||||
nread = read(client.sockfd, buf, stop? 1 : nleft);
|
||||
if( nread < 0 ) {
|
||||
Error(1000,"error reading from server");
|
||||
return -1;
|
||||
}
|
||||
else if( !nread )
|
||||
break; /* EOF */
|
||||
nleft -= nread;
|
||||
buf = (char*)buf + nread;
|
||||
if( stop )
|
||||
for(; p < (char*)buf ; p++ )
|
||||
if( *p == '\n' )
|
||||
goto leave;
|
||||
}
|
||||
leave:
|
||||
if( ret_nread )
|
||||
*ret_nread = buflen - nleft;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************
|
||||
* Like DoRead(), but append the received data to the given strgbuf.
|
||||
* read a maximum of nbytes;
|
||||
*/
|
||||
static int
|
||||
DoReadIntoStrgbuf( strgbuf_t *strgbuf, size_t nbytes, size_t *ret_nread)
|
||||
{
|
||||
size_t ntotal, nleft;
|
||||
int nread;
|
||||
byte *p, buffer[1000];
|
||||
|
||||
ntotal = 0;
|
||||
nleft = nbytes;
|
||||
while( nleft ) {
|
||||
nread = read(client.sockfd, buffer,
|
||||
nleft > DIM(buffer)? DIM(buffer) : nleft);
|
||||
if( nread < 0 ) {
|
||||
Error(1000,"error reading from server");
|
||||
return -1;
|
||||
}
|
||||
else if( !nread )
|
||||
break; /* EOF */
|
||||
nleft -= nread;
|
||||
ntotal += nread;
|
||||
/* ab in den stringbuffer */
|
||||
for(p=buffer; nread; nread--, p++ )
|
||||
PutStrgbuf(strgbuf, *p );
|
||||
}
|
||||
|
||||
if( ret_nread )
|
||||
*ret_nread = ntotal;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/****************
|
||||
* In retval wird das numerische argument nach OK zurückgegeben
|
||||
*/
|
||||
static int
|
||||
DoRequest( char *request, long *retval )
|
||||
{
|
||||
if( DoWrite(request, strlen(request)) )
|
||||
return -1;
|
||||
return DoWaitReply( retval );
|
||||
}
|
||||
|
||||
static int
|
||||
DoWaitReply( long *retval )
|
||||
{
|
||||
char *p, buf[200]; /* enough room for messages */
|
||||
size_t nread;
|
||||
|
||||
/* read but stop at the first newline */
|
||||
if( DoRead(buf, DIM(buf)-2, &nread, 1 ) )
|
||||
return -1;
|
||||
buf[DIM(buf)-1] = 0;
|
||||
/* fixme: should check, that we have the linefeed and otherwise
|
||||
* perform a dummy read */
|
||||
if( p = strchr(buf, '\n') )
|
||||
*p = 0;
|
||||
if( *buf == 'O' && buf[1] == 'K' && (buf[2]==' ' || !buf[2]) ) {
|
||||
if( retval )
|
||||
*retval = buf[2]? strtol(buf+3, NULL, 10 ):0;
|
||||
return 0;
|
||||
}
|
||||
Error(0, "Server replied: %.60s", buf );
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -308,7 +308,8 @@ int write_comment( IOBUF out, const char *s );
|
||||
|
||||
/*-- sign.c --*/
|
||||
int make_keysig_packet( PKT_signature **ret_sig, PKT_public_cert *pkc,
|
||||
PKT_user_id *uid, PKT_secret_cert *skc,
|
||||
PKT_user_id *uid, PKT_public_cert *subpkc,
|
||||
PKT_secret_cert *skc,
|
||||
int sigclass, int digest_algo );
|
||||
|
||||
#endif /*G10_PACKET_H*/
|
||||
|
@ -33,6 +33,8 @@
|
||||
#include "main.h"
|
||||
|
||||
static int pwfd = -1;
|
||||
static char *next_pw = NULL;
|
||||
static char *last_pw = NULL;
|
||||
|
||||
static void hash_passphrase( DEK *dek, char *pw, STRING2KEY *s2k, int create );
|
||||
|
||||
@ -48,6 +50,34 @@ get_passphrase_fd()
|
||||
return pwfd;
|
||||
}
|
||||
|
||||
/****************
|
||||
* Set the passphrase to be used for the next query and only for the next
|
||||
* one.
|
||||
*/
|
||||
void
|
||||
set_next_passphrase( const char *s )
|
||||
{
|
||||
m_free(next_pw);
|
||||
next_pw = NULL;
|
||||
if( s ) {
|
||||
next_pw = m_alloc_secure( strlen(s)+1 );
|
||||
strcpy(next_pw, s );
|
||||
}
|
||||
}
|
||||
|
||||
/****************
|
||||
* Get the last passphrase used in passphrase_to_dek.
|
||||
* Note: This removes the passphrase from this modules and
|
||||
* the caller must free the result. May return NULL:
|
||||
*/
|
||||
char *
|
||||
get_last_passphrase()
|
||||
{
|
||||
char *p = last_pw;
|
||||
last_pw = NULL;
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
/****************
|
||||
* Get a passphrase for the secret key with KEYID, display TEXT
|
||||
@ -62,7 +92,7 @@ get_passphrase_fd()
|
||||
DEK *
|
||||
passphrase_to_dek( u32 *keyid, int cipher_algo, STRING2KEY *s2k, int mode )
|
||||
{
|
||||
char *pw;
|
||||
char *pw = NULL;
|
||||
DEK *dek;
|
||||
STRING2KEY help_s2k;
|
||||
|
||||
@ -77,7 +107,7 @@ passphrase_to_dek( u32 *keyid, int cipher_algo, STRING2KEY *s2k, int mode )
|
||||
:DEFAULT_DIGEST_ALGO;
|
||||
}
|
||||
|
||||
if( keyid && !opt.batch ) {
|
||||
if( keyid && !opt.batch && !next_pw ) {
|
||||
char *ustr;
|
||||
tty_printf("Need a pass phrase to unlock the secret key for:\n");
|
||||
tty_printf(" \"" );
|
||||
@ -87,7 +117,11 @@ passphrase_to_dek( u32 *keyid, int cipher_algo, STRING2KEY *s2k, int mode )
|
||||
tty_printf("\"\n\n");
|
||||
|
||||
}
|
||||
if( pwfd != -1 ) { /* read the passphrase from the given descriptor */
|
||||
if( next_pw ) {
|
||||
pw = next_pw;
|
||||
next_pw = NULL;
|
||||
}
|
||||
else if( pwfd != -1 ) { /* read the passphrase from the file */
|
||||
int i, len;
|
||||
|
||||
if( !opt.batch )
|
||||
@ -130,7 +164,8 @@ passphrase_to_dek( u32 *keyid, int cipher_algo, STRING2KEY *s2k, int mode )
|
||||
dek->keylen = 0;
|
||||
else
|
||||
hash_passphrase( dek, pw, s2k, mode==2 );
|
||||
m_free(pw); /* is allocated in secure memory, so it will be burned */
|
||||
m_free(last_pw);
|
||||
last_pw = pw;
|
||||
return dek;
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,8 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx )
|
||||
if( pt->len ) {
|
||||
for( ; pt->len; pt->len-- ) {
|
||||
if( (c = iobuf_get(pt->buf)) == -1 ) {
|
||||
log_error("Problem reading source\n");
|
||||
log_error("Problem reading source (%u bytes remaining)\n",
|
||||
(unsigned)pt->len);
|
||||
rc = G10ERR_READ_FILE;
|
||||
goto leave;
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ gen_revoke( const char *uname )
|
||||
|
||||
|
||||
/* create it */
|
||||
rc = make_keysig_packet( &sig, pkc, NULL, skc, 0x20, 0);
|
||||
rc = make_keysig_packet( &sig, pkc, NULL, NULL, skc, 0x20, 0);
|
||||
if( rc ) {
|
||||
log_error("make_keysig_packet failed: %s\n", g10_errstr(rc));
|
||||
goto leave;
|
||||
|
@ -227,7 +227,7 @@ check_secret_key( PKT_secret_cert *cert )
|
||||
case PUBKEY_ALGO_ELGAMAL:
|
||||
case PUBKEY_ALGO_DSA:
|
||||
rc = do_check( cert );
|
||||
#if 1 /* set to 0 to disable the workaround */
|
||||
#if 0 /* set to 1 to enable the workaround */
|
||||
if( rc == G10ERR_BAD_PASS && cert->is_protected
|
||||
&& cert->protect.algo == CIPHER_ALGO_BLOWFISH
|
||||
&& cert->pubkey_algo != PUBKEY_ALGO_ELGAMAL ) {
|
||||
@ -243,11 +243,19 @@ check_secret_key( PKT_secret_cert *cert )
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
#ifdef HAVE_RSA_CIPHER
|
||||
case PUBKEY_ALGO_RSA:
|
||||
case PUBKEY_ALGO_RSA_E:
|
||||
case PUBKEY_ALGO_RSA_S:
|
||||
rc = do_check( cert );
|
||||
break;
|
||||
#endif
|
||||
default: rc = G10ERR_PUBKEY_ALGO;
|
||||
}
|
||||
if( get_passphrase_fd() != -1 )
|
||||
break;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
10
g10/sign.c
10
g10/sign.c
@ -170,17 +170,19 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
|
||||
|
||||
if( opt.armor && !outfile )
|
||||
iobuf_push_filter( out, armor_filter, &afx );
|
||||
else
|
||||
write_comment( out, "#created by GNUPG v" VERSION " ("
|
||||
PRINTABLE_OS_NAME ")");
|
||||
if( opt.compress && !outfile )
|
||||
iobuf_push_filter( out, compress_filter, &zfx );
|
||||
|
||||
if( encrypt ) {
|
||||
efx.pkc_list = pkc_list;
|
||||
/* fixme: set efx.cfx.datalen if known */
|
||||
iobuf_push_filter( out, encrypt_filter, &efx );
|
||||
}
|
||||
|
||||
if( opt.compress && !outfile )
|
||||
iobuf_push_filter( out, compress_filter, &zfx );
|
||||
|
||||
|
||||
if( !detached ) {
|
||||
/* loop over the secret certificates and build headers */
|
||||
for( skc_rover = skc_list; skc_rover; skc_rover = skc_rover->next ) {
|
||||
@ -410,7 +412,6 @@ int
|
||||
clearsign_file( const char *fname, STRLIST locusr, const char *outfile )
|
||||
{
|
||||
armor_filter_context_t afx;
|
||||
compress_filter_context_t zfx;
|
||||
text_filter_context_t tfx;
|
||||
MD_HANDLE textmd = NULL;
|
||||
IOBUF inp = NULL, out = NULL;
|
||||
@ -420,7 +421,6 @@ clearsign_file( const char *fname, STRLIST locusr, const char *outfile )
|
||||
SKC_LIST skc_rover = NULL;
|
||||
|
||||
memset( &afx, 0, sizeof afx);
|
||||
memset( &zfx, 0, sizeof zfx);
|
||||
memset( &tfx, 0, sizeof tfx);
|
||||
init_packet( &pkt );
|
||||
|
||||
|
@ -1,3 +1,11 @@
|
||||
Thu May 21 13:25:51 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* cipher.h: removed ROT 5 and changed one id and add dummy
|
||||
|
||||
Tue May 19 18:09:05 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* cipher.h (DIGEST_ALGO_TIGER): Chnaged id from 101 to 6.
|
||||
|
||||
Mon May 4 16:37:17 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* cipher.h (PUBKEY_ALGO_ELGAMAL_E): New, with value of the
|
||||
|
@ -42,10 +42,10 @@
|
||||
#define CIPHER_ALGO_3DES 2
|
||||
#define CIPHER_ALGO_CAST 3
|
||||
#define CIPHER_ALGO_BLOWFISH 4 /* blowfish 128 bit key */
|
||||
#define CIPHER_ALGO_ROT_N 5
|
||||
#define CIPHER_ALGO_SAFER_SK128 6
|
||||
#define CIPHER_ALGO_DES_SK 7
|
||||
#define CIPHER_ALGO_SAFER_SK128 5
|
||||
#define CIPHER_ALGO_DES_SK 6
|
||||
#define CIPHER_ALGO_BLOWFISH160 42 /* blowfish 160 bit key (not in OpenPGP)*/
|
||||
#define CIPHER_ALGO_DUMMY 110 /* no encryption at all */
|
||||
|
||||
#define PUBKEY_ALGO_RSA 1
|
||||
#define PUBKEY_ALGO_RSA_E 2 /* RSA encrypt only */
|
||||
@ -58,7 +58,7 @@
|
||||
#define DIGEST_ALGO_SHA1 2
|
||||
#define DIGEST_ALGO_RMD160 3
|
||||
#ifdef WITH_TIGER_HASH
|
||||
#define DIGEST_ALGO_TIGER 101
|
||||
#define DIGEST_ALGO_TIGER 6
|
||||
#endif
|
||||
|
||||
#define is_RSA(a) ((a)==PUBKEY_ALGO_RSA || (a)==PUBKEY_ALGO_RSA_E \
|
||||
@ -81,6 +81,7 @@ struct cipher_handle_s { char does_not_matter[1]; };
|
||||
#define CIPHER_MODE_CFB 2
|
||||
#define CIPHER_MODE_PHILS_CFB 3
|
||||
#define CIPHER_MODE_AUTO_CFB 4
|
||||
#define CIPHER_MODE_DUMMY 5 /* used with algo DUMMY for no encryption */
|
||||
|
||||
|
||||
int cipher_debug_mode;
|
||||
|
@ -1,3 +1,9 @@
|
||||
Mon May 18 13:47:06 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* config.links: split mpih-shift into mpih-[lr]shift and
|
||||
changed all implementations.
|
||||
* mpi/alpha: add some new assembler stuff.
|
||||
|
||||
Wed May 13 11:04:29 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* config.links: Add support for MIPS
|
||||
|
@ -7,7 +7,7 @@ SUFFIXES = .S .s
|
||||
|
||||
EXTRA_DIST = config.links
|
||||
DISTCLEANFILES = mpih-add1.S mpih-mul1.S mpih-mul2.S mpih-mul3.S \
|
||||
mpih-shift.S mpih-sub1.S asm-syntax.h sysdep.h
|
||||
mpih-lshift.S mpih-rshift.S mpih-sub1.S asm-syntax.h sysdep.h
|
||||
|
||||
|
||||
noinst_LIBRARIES = libmpi.a
|
||||
@ -43,7 +43,8 @@ common_asm_objects = mpih-mul1.o \
|
||||
mpih-mul3.o \
|
||||
mpih-add1.o \
|
||||
mpih-sub1.o \
|
||||
mpih-shift.o
|
||||
mpih-lshift.o \
|
||||
mpih-rshift.o
|
||||
|
||||
libmpi_a_DEPENDENCIES = $(common_asm_objects) @MPI_EXTRA_ASM_OBJS@
|
||||
libmpi_a_LIBADD = $(common_asm_objects) @MPI_EXTRA_ASM_OBJS@
|
||||
|
@ -98,7 +98,7 @@ SUFFIXES = .S .s
|
||||
|
||||
EXTRA_DIST = config.links
|
||||
DISTCLEANFILES = mpih-add1.S mpih-mul1.S mpih-mul2.S mpih-mul3.S \
|
||||
mpih-shift.S mpih-sub1.S asm-syntax.h sysdep.h
|
||||
mpih-lshift.S mpih-rshift.S mpih-sub1.S asm-syntax.h sysdep.h
|
||||
|
||||
noinst_LIBRARIES = libmpi.a
|
||||
# noinst_HEADERS =
|
||||
@ -131,7 +131,8 @@ common_asm_objects = mpih-mul1.o \
|
||||
mpih-mul3.o \
|
||||
mpih-add1.o \
|
||||
mpih-sub1.o \
|
||||
mpih-shift.o
|
||||
mpih-lshift.o \
|
||||
mpih-rshift.o
|
||||
|
||||
libmpi_a_DEPENDENCIES = $(common_asm_objects) @MPI_EXTRA_ASM_OBJS@
|
||||
libmpi_a_LIBADD = $(common_asm_objects) @MPI_EXTRA_ASM_OBJS@
|
||||
|
@ -1,6 +1,11 @@
|
||||
README
|
||||
mpih-add1.S
|
||||
mpih-shift.S
|
||||
mpih-sub1.S
|
||||
mpih-mul1.S
|
||||
mpih-mul2.S
|
||||
mpih-mul3.S
|
||||
mpih-lshift.S
|
||||
mpih-rshift.S
|
||||
|
||||
udiv-qrnnd.S
|
||||
|
||||
|
@ -19,14 +19,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
* way the data is stored; this is to support the abstraction
|
||||
* of an optional secure memory allocation which may be used
|
||||
* to avoid revealing of sensitive data due to paging etc.
|
||||
* The GNU MP Library itself is published under the LGPL;
|
||||
* however I decided to publish this code under the plain GPL.
|
||||
*/
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* alpha rshift, lshift
|
||||
/* alpha lshift
|
||||
* Copyright (C) 1994, 1995 Free Software Foundation, Inc.
|
||||
* Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
*
|
||||
@ -120,94 +120,3 @@ mpihelp_lshift:
|
||||
.end mpihelp_lshift
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* mpihelp_rshift( mpi_ptr_t wp, (r16)
|
||||
* mpi_ptr_t up, (r17)
|
||||
* mpi_size_t usize, (r18)
|
||||
* unsigned cnt) (r19)
|
||||
*
|
||||
* This code runs at 4.8 cycles/limb on the 21064. With infinite unrolling,
|
||||
* it would take 4 cycles/limb. It should be possible to get down to 3
|
||||
* cycles/limb since both ldq and stq can be paired with the other used
|
||||
* instructions. But there are many restrictions in the 21064 pipeline that
|
||||
* makes it hard, if not impossible, to get down to 3 cycles/limb:
|
||||
*
|
||||
* 1. ldq has a 3 cycle delay, srl and sll have a 2 cycle delay.
|
||||
* 2. Only aligned instruction pairs can be paired.
|
||||
* 3. The store buffer or silo might not be able to deal with the bandwidth.
|
||||
*/
|
||||
|
||||
.set noreorder
|
||||
.set noat
|
||||
.text
|
||||
.align 3
|
||||
.globl mpihelp_rshift
|
||||
.ent mpihelp_rshift
|
||||
mpihelp_rshift:
|
||||
.frame $30,0,$26,0
|
||||
|
||||
ldq $4,0($17) # load first limb
|
||||
addq $17,8,$17
|
||||
subq $31,$19,$7
|
||||
subq $18,1,$18
|
||||
and $18,4-1,$20 # number of limbs in first loop
|
||||
sll $4,$7,$0 # compute function result
|
||||
|
||||
beq $20,.R0
|
||||
subq $18,$20,$18
|
||||
|
||||
.align 3
|
||||
.Roop0:
|
||||
ldq $3,0($17)
|
||||
addq $16,8,$16
|
||||
addq $17,8,$17
|
||||
subq $20,1,$20
|
||||
srl $4,$19,$5
|
||||
sll $3,$7,$6
|
||||
bis $3,$3,$4
|
||||
bis $5,$6,$8
|
||||
stq $8,-8($16)
|
||||
bne $20,.Roop0
|
||||
|
||||
.R0: beq $18,.Rend
|
||||
|
||||
.align 3
|
||||
.Roop: ldq $3,0($17)
|
||||
addq $16,32,$16
|
||||
subq $18,4,$18
|
||||
srl $4,$19,$5
|
||||
sll $3,$7,$6
|
||||
|
||||
ldq $4,8($17)
|
||||
srl $3,$19,$1
|
||||
bis $5,$6,$8
|
||||
stq $8,-32($16)
|
||||
sll $4,$7,$2
|
||||
|
||||
ldq $3,16($17)
|
||||
srl $4,$19,$5
|
||||
bis $1,$2,$8
|
||||
stq $8,-24($16)
|
||||
sll $3,$7,$6
|
||||
|
||||
ldq $4,24($17)
|
||||
srl $3,$19,$1
|
||||
bis $5,$6,$8
|
||||
stq $8,-16($16)
|
||||
sll $4,$7,$2
|
||||
|
||||
addq $17,32,$17
|
||||
bis $1,$2,$8
|
||||
stq $8,-8($16)
|
||||
|
||||
bgt $18,.Roop
|
||||
|
||||
.Rend: srl $4,$19,$8
|
||||
stq $8,0($16)
|
||||
ret $31,($26),1
|
||||
.end mpihelp_rshift
|
||||
|
89
mpi/alpha/mpih-mul1.S
Normal file
89
mpi/alpha/mpih-mul1.S
Normal file
@ -0,0 +1,89 @@
|
||||
/* Alpha 21064 mpih-mul1.S -- Multiply a limb vector with a limb and store
|
||||
* the result in a second limb vector.
|
||||
*
|
||||
* Copyright (C) 1992, 1994, 1995, 1998 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNUPG.
|
||||
*
|
||||
* GNUPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GNUPG is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* mpihelp_mul_1( mpi_ptr_t res_ptr, (r16)
|
||||
* mpi_ptr_t s1_ptr, (r17)
|
||||
* mpi_size_t s1_size, (r18)
|
||||
* mpi_limb_t s2_limb) (r19)
|
||||
*
|
||||
* This code runs at 42 cycles/limb on the EV4 and 18 cycles/limb on the EV5.
|
||||
*
|
||||
* To improve performance for long multiplications, we would use
|
||||
* 'fetch' for S1 and 'fetch_m' for RES. It's not obvious how to use
|
||||
* these instructions without slowing down the general code: 1. We can
|
||||
* only have two prefetches in operation at any time in the Alpha
|
||||
* architecture. 2. There will seldom be any special alignment
|
||||
* between RES_PTR and S1_PTR. Maybe we can simply divide the current
|
||||
* loop into an inner and outer loop, having the inner loop handle
|
||||
* exactly one prefetch block?
|
||||
*/
|
||||
|
||||
.set noreorder
|
||||
.set noat
|
||||
.text
|
||||
.align 3
|
||||
.globl mpihelp_mul_1
|
||||
.ent mpihelp_mul_1 2
|
||||
mpihelp_mul_1:
|
||||
.frame $30,0,$26
|
||||
|
||||
ldq $2,0($17) # $2 = s1_limb
|
||||
subq $18,1,$18 # size--
|
||||
mulq $2,$19,$3 # $3 = prod_low
|
||||
bic $31,$31,$4 # clear cy_limb
|
||||
umulh $2,$19,$0 # $0 = prod_high
|
||||
beq $18,Lend1 # jump if size was == 1
|
||||
ldq $2,8($17) # $2 = s1_limb
|
||||
subq $18,1,$18 # size--
|
||||
stq $3,0($16)
|
||||
beq $18,Lend2 # jump if size was == 2
|
||||
|
||||
.align 3
|
||||
Loop: mulq $2,$19,$3 # $3 = prod_low
|
||||
addq $4,$0,$0 # cy_limb = cy_limb + 'cy'
|
||||
subq $18,1,$18 # size--
|
||||
umulh $2,$19,$4 # $4 = cy_limb
|
||||
ldq $2,16($17) # $2 = s1_limb
|
||||
addq $17,8,$17 # s1_ptr++
|
||||
addq $3,$0,$3 # $3 = cy_limb + prod_low
|
||||
stq $3,8($16)
|
||||
cmpult $3,$0,$0 # $0 = carry from (cy_limb + prod_low)
|
||||
addq $16,8,$16 # res_ptr++
|
||||
bne $18,Loop
|
||||
|
||||
Lend2: mulq $2,$19,$3 # $3 = prod_low
|
||||
addq $4,$0,$0 # cy_limb = cy_limb + 'cy'
|
||||
umulh $2,$19,$4 # $4 = cy_limb
|
||||
addq $3,$0,$3 # $3 = cy_limb + prod_low
|
||||
cmpult $3,$0,$0 # $0 = carry from (cy_limb + prod_low)
|
||||
stq $3,8($16)
|
||||
addq $4,$0,$0 # cy_limb = prod_high + cy
|
||||
ret $31,($26),1
|
||||
Lend1: stq $3,0($16)
|
||||
ret $31,($26),1
|
||||
|
||||
.end mpihelp_mul_1
|
||||
|
||||
|
96
mpi/alpha/mpih-mul2.S
Normal file
96
mpi/alpha/mpih-mul2.S
Normal file
@ -0,0 +1,96 @@
|
||||
/* Alpha 21064 addmul_1 -- Multiply a limb vector with a limb and add
|
||||
* the result to a second limb vector.
|
||||
*
|
||||
* Copyright (C) 1992, 1994, 1995, 1998 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNUPG.
|
||||
*
|
||||
* GNUPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GNUPG is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* mpihelp_addmul_1( mpi_ptr_t res_ptr, (r16)
|
||||
* mpi_ptr_t s1_ptr, (r17)
|
||||
* mpi_size_t s1_size, (r18)
|
||||
* mpi_limb_t s2_limb) (r19)
|
||||
*
|
||||
* This code runs at 42 cycles/limb on EV4 and 18 cycles/limb on EV5.
|
||||
*/
|
||||
|
||||
|
||||
.set noreorder
|
||||
.set noat
|
||||
.text
|
||||
.align 3
|
||||
.globl mpihelp_addmul_1
|
||||
.ent mpihelp_addmul_1 2
|
||||
mpihelp_addmul_1:
|
||||
.frame $30,0,$26
|
||||
|
||||
ldq $2,0($17) # $2 = s1_limb
|
||||
addq $17,8,$17 # s1_ptr++
|
||||
subq $18,1,$18 # size--
|
||||
mulq $2,$19,$3 # $3 = prod_low
|
||||
ldq $5,0($16) # $5 = *res_ptr
|
||||
umulh $2,$19,$0 # $0 = prod_high
|
||||
beq $18,.Lend1 # jump if size was == 1
|
||||
ldq $2,0($17) # $2 = s1_limb
|
||||
addq $17,8,$17 # s1_ptr++
|
||||
subq $18,1,$18 # size--
|
||||
addq $5,$3,$3
|
||||
cmpult $3,$5,$4
|
||||
stq $3,0($16)
|
||||
addq $16,8,$16 # res_ptr++
|
||||
beq $18,.Lend2 # jump if size was == 2
|
||||
|
||||
.align 3
|
||||
.Loop: mulq $2,$19,$3 # $3 = prod_low
|
||||
ldq $5,0($16) # $5 = *res_ptr
|
||||
addq $4,$0,$0 # cy_limb = cy_limb + 'cy'
|
||||
subq $18,1,$18 # size--
|
||||
umulh $2,$19,$4 # $4 = cy_limb
|
||||
ldq $2,0($17) # $2 = s1_limb
|
||||
addq $17,8,$17 # s1_ptr++
|
||||
addq $3,$0,$3 # $3 = cy_limb + prod_low
|
||||
cmpult $3,$0,$0 # $0 = carry from (cy_limb + prod_low)
|
||||
addq $5,$3,$3
|
||||
cmpult $3,$5,$5
|
||||
stq $3,0($16)
|
||||
addq $16,8,$16 # res_ptr++
|
||||
addq $5,$0,$0 # combine carries
|
||||
bne $18,.Loop
|
||||
|
||||
.Lend2: mulq $2,$19,$3 # $3 = prod_low
|
||||
ldq $5,0($16) # $5 = *res_ptr
|
||||
addq $4,$0,$0 # cy_limb = cy_limb + 'cy'
|
||||
umulh $2,$19,$4 # $4 = cy_limb
|
||||
addq $3,$0,$3 # $3 = cy_limb + prod_low
|
||||
cmpult $3,$0,$0 # $0 = carry from (cy_limb + prod_low)
|
||||
addq $5,$3,$3
|
||||
cmpult $3,$5,$5
|
||||
stq $3,0($16)
|
||||
addq $5,$0,$0 # combine carries
|
||||
addq $4,$0,$0 # cy_limb = prod_high + cy
|
||||
ret $31,($26),1
|
||||
.Lend1: addq $5,$3,$3
|
||||
cmpult $3,$5,$5
|
||||
stq $3,0($16)
|
||||
addq $0,$5,$0
|
||||
ret $31,($26),1
|
||||
|
||||
.end mpihelp_addmul_1
|
||||
|
94
mpi/alpha/mpih-mul3.S
Normal file
94
mpi/alpha/mpih-mul3.S
Normal file
@ -0,0 +1,94 @@
|
||||
/* Alpha 21064 submul_1 -- Multiply a limb vector with a limb and
|
||||
* subtract the result from a second limb vector.
|
||||
* Copyright (C) 1992, 1994, 1995, 1998 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNUPG.
|
||||
*
|
||||
* GNUPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GNUPG is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* mpihelp_submul_1( mpi_ptr_t res_ptr, (r16 )
|
||||
* mpi_ptr_t s1_ptr, (r17 )
|
||||
* mpi_size_t s1_size, (r18 )
|
||||
* mpi_limb_t s2_limb) (r19 )
|
||||
*
|
||||
* This code runs at 42 cycles/limb on EV4 and 18 cycles/limb on EV5.
|
||||
*/
|
||||
|
||||
.set noreorder
|
||||
.set noat
|
||||
.text
|
||||
.align 3
|
||||
.globl mpihelp_submul_1
|
||||
.ent mpihelp_submul_1 2
|
||||
mpihelp_submul_1:
|
||||
.frame $30,0,$26
|
||||
|
||||
ldq $2,0($17) # $2 = s1_limb
|
||||
addq $17,8,$17 # s1_ptr++
|
||||
subq $18,1,$18 # size--
|
||||
mulq $2,$19,$3 # $3 = prod_low
|
||||
ldq $5,0($16) # $5 = *res_ptr
|
||||
umulh $2,$19,$0 # $0 = prod_high
|
||||
beq $18,.Lend1 # jump if size was == 1
|
||||
ldq $2,0($17) # $2 = s1_limb
|
||||
addq $17,8,$17 # s1_ptr++
|
||||
subq $18,1,$18 # size--
|
||||
subq $5,$3,$3
|
||||
cmpult $5,$3,$4
|
||||
stq $3,0($16)
|
||||
addq $16,8,$16 # res_ptr++
|
||||
beq $18,.Lend2 # jump if size was == 2
|
||||
|
||||
.align 3
|
||||
.Loop: mulq $2,$19,$3 # $3 = prod_low
|
||||
ldq $5,0($16) # $5 = *res_ptr
|
||||
addq $4,$0,$0 # cy_limb = cy_limb + 'cy'
|
||||
subq $18,1,$18 # size--
|
||||
umulh $2,$19,$4 # $4 = cy_limb
|
||||
ldq $2,0($17) # $2 = s1_limb
|
||||
addq $17,8,$17 # s1_ptr++
|
||||
addq $3,$0,$3 # $3 = cy_limb + prod_low
|
||||
cmpult $3,$0,$0 # $0 = carry from (cy_limb + prod_low)
|
||||
subq $5,$3,$3
|
||||
cmpult $5,$3,$5
|
||||
stq $3,0($16)
|
||||
addq $16,8,$16 # res_ptr++
|
||||
addq $5,$0,$0 # combine carries
|
||||
bne $18,.Loop
|
||||
|
||||
.Lend2: mulq $2,$19,$3 # $3 = prod_low
|
||||
ldq $5,0($16) # $5 = *res_ptr
|
||||
addq $4,$0,$0 # cy_limb = cy_limb + 'cy'
|
||||
umulh $2,$19,$4 # $4 = cy_limb
|
||||
addq $3,$0,$3 # $3 = cy_limb + prod_low
|
||||
cmpult $3,$0,$0 # $0 = carry from (cy_limb + prod_low)
|
||||
subq $5,$3,$3
|
||||
cmpult $5,$3,$5
|
||||
stq $3,0($16)
|
||||
addq $5,$0,$0 # combine carries
|
||||
addq $4,$0,$0 # cy_limb = prod_high + cy
|
||||
ret $31,($26),1
|
||||
.Lend1: subq $5,$3,$3
|
||||
cmpult $5,$3,$5
|
||||
stq $3,0($16)
|
||||
addq $0,$5,$0
|
||||
ret $31,($26),1
|
||||
|
||||
.end mpihelp_submul_1
|
||||
|
120
mpi/alpha/mpih-rshift.S
Normal file
120
mpi/alpha/mpih-rshift.S
Normal file
@ -0,0 +1,120 @@
|
||||
/* alpha rshift
|
||||
* Copyright (C) 1994, 1995 Free Software Foundation, Inc.
|
||||
* Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNUPG.
|
||||
*
|
||||
* GNUPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GNUPG is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
* way the data is stored; this is to support the abstraction
|
||||
* of an optional secure memory allocation which may be used
|
||||
* to avoid revealing of sensitive data due to paging etc.
|
||||
* The GNU MP Library itself is published under the LGPL;
|
||||
* however I decided to publish this code under the plain GPL.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* mpihelp_rshift( mpi_ptr_t wp, (r16)
|
||||
* mpi_ptr_t up, (r17)
|
||||
* mpi_size_t usize, (r18)
|
||||
* unsigned cnt) (r19)
|
||||
*
|
||||
* This code runs at 4.8 cycles/limb on the 21064. With infinite unrolling,
|
||||
* it would take 4 cycles/limb. It should be possible to get down to 3
|
||||
* cycles/limb since both ldq and stq can be paired with the other used
|
||||
* instructions. But there are many restrictions in the 21064 pipeline that
|
||||
* makes it hard, if not impossible, to get down to 3 cycles/limb:
|
||||
*
|
||||
* 1. ldq has a 3 cycle delay, srl and sll have a 2 cycle delay.
|
||||
* 2. Only aligned instruction pairs can be paired.
|
||||
* 3. The store buffer or silo might not be able to deal with the bandwidth.
|
||||
*/
|
||||
|
||||
.set noreorder
|
||||
.set noat
|
||||
.text
|
||||
.align 3
|
||||
.globl mpihelp_rshift
|
||||
.ent mpihelp_rshift
|
||||
mpihelp_rshift:
|
||||
.frame $30,0,$26,0
|
||||
|
||||
ldq $4,0($17) # load first limb
|
||||
addq $17,8,$17
|
||||
subq $31,$19,$7
|
||||
subq $18,1,$18
|
||||
and $18,4-1,$20 # number of limbs in first loop
|
||||
sll $4,$7,$0 # compute function result
|
||||
|
||||
beq $20,.R0
|
||||
subq $18,$20,$18
|
||||
|
||||
.align 3
|
||||
.Roop0:
|
||||
ldq $3,0($17)
|
||||
addq $16,8,$16
|
||||
addq $17,8,$17
|
||||
subq $20,1,$20
|
||||
srl $4,$19,$5
|
||||
sll $3,$7,$6
|
||||
bis $3,$3,$4
|
||||
bis $5,$6,$8
|
||||
stq $8,-8($16)
|
||||
bne $20,.Roop0
|
||||
|
||||
.R0: beq $18,.Rend
|
||||
|
||||
.align 3
|
||||
.Roop: ldq $3,0($17)
|
||||
addq $16,32,$16
|
||||
subq $18,4,$18
|
||||
srl $4,$19,$5
|
||||
sll $3,$7,$6
|
||||
|
||||
ldq $4,8($17)
|
||||
srl $3,$19,$1
|
||||
bis $5,$6,$8
|
||||
stq $8,-32($16)
|
||||
sll $4,$7,$2
|
||||
|
||||
ldq $3,16($17)
|
||||
srl $4,$19,$5
|
||||
bis $1,$2,$8
|
||||
stq $8,-24($16)
|
||||
sll $3,$7,$6
|
||||
|
||||
ldq $4,24($17)
|
||||
srl $3,$19,$1
|
||||
bis $5,$6,$8
|
||||
stq $8,-16($16)
|
||||
sll $4,$7,$2
|
||||
|
||||
addq $17,32,$17
|
||||
bis $1,$2,$8
|
||||
stq $8,-8($16)
|
||||
|
||||
bgt $18,.Roop
|
||||
|
||||
.Rend: srl $4,$19,$8
|
||||
stq $8,0($16)
|
||||
ret $31,($26),1
|
||||
.end mpihelp_rshift
|
||||
|
123
mpi/alpha/mpih-sub1.S
Normal file
123
mpi/alpha/mpih-sub1.S
Normal file
@ -0,0 +1,123 @@
|
||||
/* Alpha sub_n -- Subtract two limb vectors of the same length > 0 and
|
||||
* store difference in a third limb vector.
|
||||
* Copyright (C) 1995, 1998 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNUPG.
|
||||
*
|
||||
* GNUPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GNUPG is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* mpihelp_sub_n( mpi_ptr_t res_ptr, (r16)
|
||||
* mpi_ptr_t s1_ptr, (r17)
|
||||
* mpi_ptr_t s2_ptr, (r18)
|
||||
* mpi_size_t size) (r19)
|
||||
*/
|
||||
|
||||
.set noreorder
|
||||
.set noat
|
||||
.text
|
||||
.align 3
|
||||
.globl mpihelp_sub_n
|
||||
.ent mpihelp_sub_n
|
||||
mpihelp_sub_n:
|
||||
.frame $30,0,$26,0
|
||||
|
||||
ldq $3,0($17)
|
||||
ldq $4,0($18)
|
||||
|
||||
subq $19,1,$19
|
||||
and $19,4-1,$2 # number of limbs in first loop
|
||||
bis $31,$31,$0
|
||||
beq $2,.L0 # if multiple of 4 limbs, skip first loop
|
||||
|
||||
subq $19,$2,$19
|
||||
|
||||
.Loop0: subq $2,1,$2
|
||||
ldq $5,8($17)
|
||||
addq $4,$0,$4
|
||||
ldq $6,8($18)
|
||||
cmpult $4,$0,$1
|
||||
subq $3,$4,$4
|
||||
cmpult $3,$4,$0
|
||||
stq $4,0($16)
|
||||
or $0,$1,$0
|
||||
|
||||
addq $17,8,$17
|
||||
addq $18,8,$18
|
||||
bis $5,$5,$3
|
||||
bis $6,$6,$4
|
||||
addq $16,8,$16
|
||||
bne $2,.Loop0
|
||||
|
||||
.L0: beq $19,.Lend
|
||||
|
||||
.align 3
|
||||
.Loop: subq $19,4,$19
|
||||
|
||||
ldq $5,8($17)
|
||||
addq $4,$0,$4
|
||||
ldq $6,8($18)
|
||||
cmpult $4,$0,$1
|
||||
subq $3,$4,$4
|
||||
cmpult $3,$4,$0
|
||||
stq $4,0($16)
|
||||
or $0,$1,$0
|
||||
|
||||
ldq $3,16($17)
|
||||
addq $6,$0,$6
|
||||
ldq $4,16($18)
|
||||
cmpult $6,$0,$1
|
||||
subq $5,$6,$6
|
||||
cmpult $5,$6,$0
|
||||
stq $6,8($16)
|
||||
or $0,$1,$0
|
||||
|
||||
ldq $5,24($17)
|
||||
addq $4,$0,$4
|
||||
ldq $6,24($18)
|
||||
cmpult $4,$0,$1
|
||||
subq $3,$4,$4
|
||||
cmpult $3,$4,$0
|
||||
stq $4,16($16)
|
||||
or $0,$1,$0
|
||||
|
||||
ldq $3,32($17)
|
||||
addq $6,$0,$6
|
||||
ldq $4,32($18)
|
||||
cmpult $6,$0,$1
|
||||
subq $5,$6,$6
|
||||
cmpult $5,$6,$0
|
||||
stq $6,24($16)
|
||||
or $0,$1,$0
|
||||
|
||||
addq $17,32,$17
|
||||
addq $18,32,$18
|
||||
addq $16,32,$16
|
||||
bne $19,.Loop
|
||||
|
||||
.Lend: addq $4,$0,$4
|
||||
cmpult $4,$0,$1
|
||||
subq $3,$4,$4
|
||||
cmpult $3,$4,$0
|
||||
stq $4,0($16)
|
||||
or $0,$1,$0
|
||||
ret $31,($26),1
|
||||
|
||||
.end mpihelp_sub_n
|
||||
|
||||
|
@ -150,7 +150,7 @@ fi
|
||||
|
||||
# fixme: grep these modules from Makefile.in
|
||||
mpi_ln_modules="${mpi_extra_modules} mpih-add1 mpih-mul1 mpih-mul2 mpih-mul3 \
|
||||
mpih-shift mpih-sub1"
|
||||
mpih-lshift mpih-rshift mpih-sub1"
|
||||
|
||||
mpi_ln_objects=
|
||||
mpi_ln_src=
|
||||
|
@ -2,6 +2,7 @@ mpih-add1.c
|
||||
mpih-mul1.c
|
||||
mpih-mul2.c
|
||||
mpih-mul3.c
|
||||
mpih-shift.c
|
||||
mpih-lshift.c
|
||||
mpih-rshift.c
|
||||
mpih-sub1.c
|
||||
|
||||
|
@ -2,5 +2,6 @@ README
|
||||
udiv-qrnnd.S
|
||||
mpih-add1.S
|
||||
mpih-sub1.S
|
||||
mpih-shift.S
|
||||
mpih-lshift.S
|
||||
mpih-rshift.S
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* hppa rshift, lshift
|
||||
* Copyright (C) 1992, 1994 Free Software Foundation, Inc.
|
||||
* Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
/* hppa lshift
|
||||
*
|
||||
* Copyright (C) 1992, 1994, 1998 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNUPG.
|
||||
*
|
||||
@ -17,14 +17,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
* way the data is stored; this is to support the abstraction
|
||||
* of an optional secure memory allocation which may be used
|
||||
* to avoid revealing of sensitive data due to paging etc.
|
||||
* The GNU MP Library itself is published under the LGPL;
|
||||
* however I decided to publish this code under the plain GPL.
|
||||
*/
|
||||
|
||||
|
||||
@ -78,47 +70,3 @@ L$0004 vshd %r22,%r0,%r20
|
||||
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* mpihelp_rshift( mpi_ptr_t wp, (gr26)
|
||||
* mpi_ptr_t up, (gr25)
|
||||
* mpi_size_t usize, (gr24)
|
||||
* unsigned cnt) (gr23)
|
||||
*/
|
||||
|
||||
.code
|
||||
.export mpihelp_rshift
|
||||
mpihelp_rshift
|
||||
.proc
|
||||
.callinfo frame=64,no_calls
|
||||
.entry
|
||||
|
||||
ldws,ma 4(0,%r25),%r22
|
||||
mtsar %r23
|
||||
addib,= -1,%r24,L$r004
|
||||
vshd %r22,%r0,%r28 ; compute carry out limb
|
||||
ldws,ma 4(0,%r25),%r29
|
||||
addib,= -1,%r24,L$r002
|
||||
vshd %r29,%r22,%r20
|
||||
|
||||
L$roop ldws,ma 4(0,%r25),%r22
|
||||
stws,ma %r20,4(0,%r26)
|
||||
addib,= -1,%r24,L$r003
|
||||
vshd %r22,%r29,%r20
|
||||
ldws,ma 4(0,%r25),%r29
|
||||
stws,ma %r20,4(0,%r26)
|
||||
addib,<> -1,%r24,L$roop
|
||||
vshd %r29,%r22,%r20
|
||||
|
||||
L$r002 stws,ma %r20,4(0,%r26)
|
||||
vshd %r0,%r29,%r20
|
||||
bv 0(%r2)
|
||||
stw %r20,0(0,%r26)
|
||||
L$r003 stws,ma %r20,4(0,%r26)
|
||||
L$r004 vshd %r0,%r22,%r20
|
||||
bv 0(%r2)
|
||||
stw %r20,0(0,%r26)
|
||||
|
||||
.exit
|
||||
.procend
|
||||
|
68
mpi/hppa/mpih-rshift.S
Normal file
68
mpi/hppa/mpih-rshift.S
Normal file
@ -0,0 +1,68 @@
|
||||
/* hppa rshift
|
||||
*
|
||||
* Copyright (C) 1992, 1994, 1998 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNUPG.
|
||||
*
|
||||
* GNUPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GNUPG is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* mpihelp_rshift( mpi_ptr_t wp, (gr26)
|
||||
* mpi_ptr_t up, (gr25)
|
||||
* mpi_size_t usize, (gr24)
|
||||
* unsigned cnt) (gr23)
|
||||
*/
|
||||
|
||||
.code
|
||||
.export mpihelp_rshift
|
||||
mpihelp_rshift
|
||||
.proc
|
||||
.callinfo frame=64,no_calls
|
||||
.entry
|
||||
|
||||
ldws,ma 4(0,%r25),%r22
|
||||
mtsar %r23
|
||||
addib,= -1,%r24,L$r004
|
||||
vshd %r22,%r0,%r28 ; compute carry out limb
|
||||
ldws,ma 4(0,%r25),%r29
|
||||
addib,= -1,%r24,L$r002
|
||||
vshd %r29,%r22,%r20
|
||||
|
||||
L$roop ldws,ma 4(0,%r25),%r22
|
||||
stws,ma %r20,4(0,%r26)
|
||||
addib,= -1,%r24,L$r003
|
||||
vshd %r22,%r29,%r20
|
||||
ldws,ma 4(0,%r25),%r29
|
||||
stws,ma %r20,4(0,%r26)
|
||||
addib,<> -1,%r24,L$roop
|
||||
vshd %r29,%r22,%r20
|
||||
|
||||
L$r002 stws,ma %r20,4(0,%r26)
|
||||
vshd %r0,%r29,%r20
|
||||
bv 0(%r2)
|
||||
stw %r20,0(0,%r26)
|
||||
L$r003 stws,ma %r20,4(0,%r26)
|
||||
L$r004 vshd %r0,%r22,%r20
|
||||
bv 0(%r2)
|
||||
stw %r20,0(0,%r26)
|
||||
|
||||
.exit
|
||||
.procend
|
||||
|
@ -2,7 +2,8 @@ mpih-add1.S
|
||||
mpih-mul1.S
|
||||
mpih-mul2.S
|
||||
mpih-mul3.S
|
||||
mpih-shift.S
|
||||
mpih-lshift.S
|
||||
mpih-rshift.S
|
||||
mpih-sub1.S
|
||||
syntax.h
|
||||
|
||||
|
96
mpi/i386/mpih-lshift.S
Normal file
96
mpi/i386/mpih-lshift.S
Normal file
@ -0,0 +1,96 @@
|
||||
/* i80386 lshift
|
||||
* Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
* Copyright (C) 1992, 1994 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNUPG.
|
||||
*
|
||||
* GNUPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GNUPG is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
* way the data is stored; this is to support the abstraction
|
||||
* of an optional secure memory allocation which may be used
|
||||
* to avoid revealing of sensitive data due to paging etc.
|
||||
* The GNU MP Library itself is published under the LGPL;
|
||||
* however I decided to publish this code under the plain GPL.
|
||||
*/
|
||||
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* mpihelp_lshift( mpi_ptr_t wp, (sp + 4)
|
||||
* mpi_ptr_t up, (sp + 8)
|
||||
* mpi_size_t usize, (sp + 12)
|
||||
* unsigned cnt) (sp + 16)
|
||||
*/
|
||||
|
||||
.text
|
||||
ALIGN (3)
|
||||
.globl C_SYMBOL_NAME(mpihelp_lshift)
|
||||
C_SYMBOL_NAME(mpihelp_lshift:)
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
|
||||
movl 16(%esp),%edi /* res_ptr */
|
||||
movl 20(%esp),%esi /* s_ptr */
|
||||
movl 24(%esp),%edx /* size */
|
||||
movl 28(%esp),%ecx /* cnt */
|
||||
|
||||
subl $4,%esi /* adjust s_ptr */
|
||||
|
||||
movl (%esi,%edx,4),%ebx /* read most significant limb */
|
||||
xorl %eax,%eax
|
||||
shldl %cl,%ebx,%eax /* compute carry limb */
|
||||
decl %edx
|
||||
jz Lend
|
||||
pushl %eax /* push carry limb onto stack */
|
||||
testb $1,%edx
|
||||
jnz L1 /* enter loop in the middle */
|
||||
movl %ebx,%eax
|
||||
|
||||
ALIGN (3)
|
||||
Loop: movl (%esi,%edx,4),%ebx /* load next lower limb */
|
||||
shldl %cl,%ebx,%eax /* compute result limb */
|
||||
movl %eax,(%edi,%edx,4) /* store it */
|
||||
decl %edx
|
||||
L1: movl (%esi,%edx,4),%eax
|
||||
shldl %cl,%eax,%ebx
|
||||
movl %ebx,(%edi,%edx,4)
|
||||
decl %edx
|
||||
jnz Loop
|
||||
|
||||
shll %cl,%eax /* compute least significant limb */
|
||||
movl %eax,(%edi) /* store it */
|
||||
|
||||
popl %eax /* pop carry limb */
|
||||
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
|
||||
Lend: shll %cl,%ebx /* compute least significant limb */
|
||||
movl %ebx,(%edi) /* store it */
|
||||
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* i80386 rshift, lshift
|
||||
/* i80386 rshift
|
||||
* Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
* Copyright (C) 1992, 1994 Free Software Foundation, Inc.
|
||||
*
|
||||
@ -32,68 +32,6 @@
|
||||
#include "asm-syntax.h"
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* mpihelp_lshift( mpi_ptr_t wp, (sp + 4)
|
||||
* mpi_ptr_t up, (sp + 8)
|
||||
* mpi_size_t usize, (sp + 12)
|
||||
* unsigned cnt) (sp + 16)
|
||||
*/
|
||||
|
||||
.text
|
||||
ALIGN (3)
|
||||
.globl C_SYMBOL_NAME(mpihelp_lshift)
|
||||
C_SYMBOL_NAME(mpihelp_lshift:)
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
|
||||
movl 16(%esp),%edi /* res_ptr */
|
||||
movl 20(%esp),%esi /* s_ptr */
|
||||
movl 24(%esp),%edx /* size */
|
||||
movl 28(%esp),%ecx /* cnt */
|
||||
|
||||
subl $4,%esi /* adjust s_ptr */
|
||||
|
||||
movl (%esi,%edx,4),%ebx /* read most significant limb */
|
||||
xorl %eax,%eax
|
||||
shldl %cl,%ebx,%eax /* compute carry limb */
|
||||
decl %edx
|
||||
jz Lend
|
||||
pushl %eax /* push carry limb onto stack */
|
||||
testb $1,%edx
|
||||
jnz L1 /* enter loop in the middle */
|
||||
movl %ebx,%eax
|
||||
|
||||
ALIGN (3)
|
||||
Loop: movl (%esi,%edx,4),%ebx /* load next lower limb */
|
||||
shldl %cl,%ebx,%eax /* compute result limb */
|
||||
movl %eax,(%edi,%edx,4) /* store it */
|
||||
decl %edx
|
||||
L1: movl (%esi,%edx,4),%eax
|
||||
shldl %cl,%eax,%ebx
|
||||
movl %ebx,(%edi,%edx,4)
|
||||
decl %edx
|
||||
jnz Loop
|
||||
|
||||
shll %cl,%eax /* compute least significant limb */
|
||||
movl %eax,(%edi) /* store it */
|
||||
|
||||
popl %eax /* pop carry limb */
|
||||
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
|
||||
Lend: shll %cl,%ebx /* compute least significant limb */
|
||||
movl %ebx,(%edi) /* store it */
|
||||
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* mpihelp_rshift( mpi_ptr_t wp, (sp + 4)
|
@ -2,7 +2,8 @@ mpih-add1.S
|
||||
mpih-mul1.S
|
||||
mpih-mul2.S
|
||||
mpih-mul3.S
|
||||
mpih-shift.S
|
||||
mpih-lshift.S
|
||||
mpih-rshift.S
|
||||
mpih-sub1.S
|
||||
README
|
||||
|
||||
|
230
mpi/i586/mpih-lshift.S
Normal file
230
mpi/i586/mpih-lshift.S
Normal file
@ -0,0 +1,230 @@
|
||||
/* i80586 lshift
|
||||
* Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
* Copyright (C) 1992, 1994 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNUPG.
|
||||
*
|
||||
* GNUPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GNUPG is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
* way the data is stored; this is to support the abstraction
|
||||
* of an optional secure memory allocation which may be used
|
||||
* to avoid revealing of sensitive data due to paging etc.
|
||||
* The GNU MP Library itself is published under the LGPL;
|
||||
* however I decided to publish this code under the plain GPL.
|
||||
*/
|
||||
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* mpihelp_lshift( mpi_ptr_t wp, (sp + 4)
|
||||
* mpi_ptr_t up, (sp + 8)
|
||||
* mpi_size_t usize, (sp + 12)
|
||||
* unsigned cnt) (sp + 16)
|
||||
*/
|
||||
|
||||
.text
|
||||
ALIGN (3)
|
||||
.globl C_SYMBOL_NAME(mpihelp_lshift)
|
||||
C_SYMBOL_NAME(mpihelp_lshift:)
|
||||
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
pushl %ebp
|
||||
|
||||
movl 20(%esp),%edi /* res_ptr */
|
||||
movl 24(%esp),%esi /* s_ptr */
|
||||
movl 28(%esp),%ebp /* size */
|
||||
movl 32(%esp),%ecx /* cnt */
|
||||
|
||||
/* We can use faster code for shift-by-1 under certain conditions. */
|
||||
cmp $1,%ecx
|
||||
jne Lnormal
|
||||
leal 4(%esi),%eax
|
||||
cmpl %edi,%eax
|
||||
jnc Lspecial /* jump if s_ptr + 1 >= res_ptr */
|
||||
leal (%esi,%ebp,4),%eax
|
||||
cmpl %eax,%edi
|
||||
jnc Lspecial /* jump if res_ptr >= s_ptr + size */
|
||||
|
||||
Lnormal:
|
||||
leal -4(%edi,%ebp,4),%edi
|
||||
leal -4(%esi,%ebp,4),%esi
|
||||
|
||||
movl (%esi),%edx
|
||||
subl $4,%esi
|
||||
xorl %eax,%eax
|
||||
shldl %cl,%edx,%eax /* compute carry limb */
|
||||
pushl %eax /* push carry limb onto stack */
|
||||
|
||||
decl %ebp
|
||||
pushl %ebp
|
||||
shrl $3,%ebp
|
||||
jz Lend
|
||||
|
||||
movl (%edi),%eax /* fetch destination cache line */
|
||||
|
||||
ALIGN (2)
|
||||
Loop: movl -28(%edi),%eax /* fetch destination cache line */
|
||||
movl %edx,%ebx
|
||||
|
||||
movl (%esi),%eax
|
||||
movl -4(%esi),%edx
|
||||
shldl %cl,%eax,%ebx
|
||||
shldl %cl,%edx,%eax
|
||||
movl %ebx,(%edi)
|
||||
movl %eax,-4(%edi)
|
||||
|
||||
movl -8(%esi),%ebx
|
||||
movl -12(%esi),%eax
|
||||
shldl %cl,%ebx,%edx
|
||||
shldl %cl,%eax,%ebx
|
||||
movl %edx,-8(%edi)
|
||||
movl %ebx,-12(%edi)
|
||||
|
||||
movl -16(%esi),%edx
|
||||
movl -20(%esi),%ebx
|
||||
shldl %cl,%edx,%eax
|
||||
shldl %cl,%ebx,%edx
|
||||
movl %eax,-16(%edi)
|
||||
movl %edx,-20(%edi)
|
||||
|
||||
movl -24(%esi),%eax
|
||||
movl -28(%esi),%edx
|
||||
shldl %cl,%eax,%ebx
|
||||
shldl %cl,%edx,%eax
|
||||
movl %ebx,-24(%edi)
|
||||
movl %eax,-28(%edi)
|
||||
|
||||
subl $32,%esi
|
||||
subl $32,%edi
|
||||
decl %ebp
|
||||
jnz Loop
|
||||
|
||||
Lend: popl %ebp
|
||||
andl $7,%ebp
|
||||
jz Lend2
|
||||
Loop2: movl (%esi),%eax
|
||||
shldl %cl,%eax,%edx
|
||||
movl %edx,(%edi)
|
||||
movl %eax,%edx
|
||||
subl $4,%esi
|
||||
subl $4,%edi
|
||||
decl %ebp
|
||||
jnz Loop2
|
||||
|
||||
Lend2: shll %cl,%edx /* compute least significant limb */
|
||||
movl %edx,(%edi) /* store it */
|
||||
|
||||
popl %eax /* pop carry limb */
|
||||
|
||||
popl %ebp
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
|
||||
/* We loop from least significant end of the arrays, which is only
|
||||
permissable if the source and destination don't overlap, since the
|
||||
function is documented to work for overlapping source and destination.
|
||||
*/
|
||||
|
||||
Lspecial:
|
||||
movl (%esi),%edx
|
||||
addl $4,%esi
|
||||
|
||||
decl %ebp
|
||||
pushl %ebp
|
||||
shrl $3,%ebp
|
||||
|
||||
addl %edx,%edx
|
||||
incl %ebp
|
||||
decl %ebp
|
||||
jz LLend
|
||||
|
||||
movl (%edi),%eax /* fetch destination cache line */
|
||||
|
||||
ALIGN (2)
|
||||
LLoop: movl 28(%edi),%eax /* fetch destination cache line */
|
||||
movl %edx,%ebx
|
||||
|
||||
movl (%esi),%eax
|
||||
movl 4(%esi),%edx
|
||||
adcl %eax,%eax
|
||||
movl %ebx,(%edi)
|
||||
adcl %edx,%edx
|
||||
movl %eax,4(%edi)
|
||||
|
||||
movl 8(%esi),%ebx
|
||||
movl 12(%esi),%eax
|
||||
adcl %ebx,%ebx
|
||||
movl %edx,8(%edi)
|
||||
adcl %eax,%eax
|
||||
movl %ebx,12(%edi)
|
||||
|
||||
movl 16(%esi),%edx
|
||||
movl 20(%esi),%ebx
|
||||
adcl %edx,%edx
|
||||
movl %eax,16(%edi)
|
||||
adcl %ebx,%ebx
|
||||
movl %edx,20(%edi)
|
||||
|
||||
movl 24(%esi),%eax
|
||||
movl 28(%esi),%edx
|
||||
adcl %eax,%eax
|
||||
movl %ebx,24(%edi)
|
||||
adcl %edx,%edx
|
||||
movl %eax,28(%edi)
|
||||
|
||||
leal 32(%esi),%esi /* use leal not to clobber carry */
|
||||
leal 32(%edi),%edi
|
||||
decl %ebp
|
||||
jnz LLoop
|
||||
|
||||
LLend: popl %ebp
|
||||
sbbl %eax,%eax /* save carry in %eax */
|
||||
andl $7,%ebp
|
||||
jz LLend2
|
||||
addl %eax,%eax /* restore carry from eax */
|
||||
LLoop2: movl %edx,%ebx
|
||||
movl (%esi),%edx
|
||||
adcl %edx,%edx
|
||||
movl %ebx,(%edi)
|
||||
|
||||
leal 4(%esi),%esi /* use leal not to clobber carry */
|
||||
leal 4(%edi),%edi
|
||||
decl %ebp
|
||||
jnz LLoop2
|
||||
|
||||
jmp LL1
|
||||
LLend2: addl %eax,%eax /* restore carry from eax */
|
||||
LL1: movl %edx,(%edi) /* store last limb */
|
||||
|
||||
sbbl %eax,%eax
|
||||
negl %eax
|
||||
|
||||
popl %ebp
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* i80586 rshift, lshift
|
||||
/* i80586 rshift
|
||||
* Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
* Copyright (C) 1992, 1994 Free Software Foundation, Inc.
|
||||
*
|
||||
@ -32,203 +32,6 @@
|
||||
#include "asm-syntax.h"
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* mpihelp_lshift( mpi_ptr_t wp, (sp + 4)
|
||||
* mpi_ptr_t up, (sp + 8)
|
||||
* mpi_size_t usize, (sp + 12)
|
||||
* unsigned cnt) (sp + 16)
|
||||
*/
|
||||
|
||||
.text
|
||||
ALIGN (3)
|
||||
.globl C_SYMBOL_NAME(mpihelp_lshift)
|
||||
C_SYMBOL_NAME(mpihelp_lshift:)
|
||||
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
pushl %ebp
|
||||
|
||||
movl 20(%esp),%edi /* res_ptr */
|
||||
movl 24(%esp),%esi /* s_ptr */
|
||||
movl 28(%esp),%ebp /* size */
|
||||
movl 32(%esp),%ecx /* cnt */
|
||||
|
||||
/* We can use faster code for shift-by-1 under certain conditions. */
|
||||
cmp $1,%ecx
|
||||
jne Lnormal
|
||||
leal 4(%esi),%eax
|
||||
cmpl %edi,%eax
|
||||
jnc Lspecial /* jump if s_ptr + 1 >= res_ptr */
|
||||
leal (%esi,%ebp,4),%eax
|
||||
cmpl %eax,%edi
|
||||
jnc Lspecial /* jump if res_ptr >= s_ptr + size */
|
||||
|
||||
Lnormal:
|
||||
leal -4(%edi,%ebp,4),%edi
|
||||
leal -4(%esi,%ebp,4),%esi
|
||||
|
||||
movl (%esi),%edx
|
||||
subl $4,%esi
|
||||
xorl %eax,%eax
|
||||
shldl %cl,%edx,%eax /* compute carry limb */
|
||||
pushl %eax /* push carry limb onto stack */
|
||||
|
||||
decl %ebp
|
||||
pushl %ebp
|
||||
shrl $3,%ebp
|
||||
jz Lend
|
||||
|
||||
movl (%edi),%eax /* fetch destination cache line */
|
||||
|
||||
ALIGN (2)
|
||||
Loop: movl -28(%edi),%eax /* fetch destination cache line */
|
||||
movl %edx,%ebx
|
||||
|
||||
movl (%esi),%eax
|
||||
movl -4(%esi),%edx
|
||||
shldl %cl,%eax,%ebx
|
||||
shldl %cl,%edx,%eax
|
||||
movl %ebx,(%edi)
|
||||
movl %eax,-4(%edi)
|
||||
|
||||
movl -8(%esi),%ebx
|
||||
movl -12(%esi),%eax
|
||||
shldl %cl,%ebx,%edx
|
||||
shldl %cl,%eax,%ebx
|
||||
movl %edx,-8(%edi)
|
||||
movl %ebx,-12(%edi)
|
||||
|
||||
movl -16(%esi),%edx
|
||||
movl -20(%esi),%ebx
|
||||
shldl %cl,%edx,%eax
|
||||
shldl %cl,%ebx,%edx
|
||||
movl %eax,-16(%edi)
|
||||
movl %edx,-20(%edi)
|
||||
|
||||
movl -24(%esi),%eax
|
||||
movl -28(%esi),%edx
|
||||
shldl %cl,%eax,%ebx
|
||||
shldl %cl,%edx,%eax
|
||||
movl %ebx,-24(%edi)
|
||||
movl %eax,-28(%edi)
|
||||
|
||||
subl $32,%esi
|
||||
subl $32,%edi
|
||||
decl %ebp
|
||||
jnz Loop
|
||||
|
||||
Lend: popl %ebp
|
||||
andl $7,%ebp
|
||||
jz Lend2
|
||||
Loop2: movl (%esi),%eax
|
||||
shldl %cl,%eax,%edx
|
||||
movl %edx,(%edi)
|
||||
movl %eax,%edx
|
||||
subl $4,%esi
|
||||
subl $4,%edi
|
||||
decl %ebp
|
||||
jnz Loop2
|
||||
|
||||
Lend2: shll %cl,%edx /* compute least significant limb */
|
||||
movl %edx,(%edi) /* store it */
|
||||
|
||||
popl %eax /* pop carry limb */
|
||||
|
||||
popl %ebp
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
|
||||
/* We loop from least significant end of the arrays, which is only
|
||||
permissable if the source and destination don't overlap, since the
|
||||
function is documented to work for overlapping source and destination.
|
||||
*/
|
||||
|
||||
Lspecial:
|
||||
movl (%esi),%edx
|
||||
addl $4,%esi
|
||||
|
||||
decl %ebp
|
||||
pushl %ebp
|
||||
shrl $3,%ebp
|
||||
|
||||
addl %edx,%edx
|
||||
incl %ebp
|
||||
decl %ebp
|
||||
jz LLend
|
||||
|
||||
movl (%edi),%eax /* fetch destination cache line */
|
||||
|
||||
ALIGN (2)
|
||||
LLoop: movl 28(%edi),%eax /* fetch destination cache line */
|
||||
movl %edx,%ebx
|
||||
|
||||
movl (%esi),%eax
|
||||
movl 4(%esi),%edx
|
||||
adcl %eax,%eax
|
||||
movl %ebx,(%edi)
|
||||
adcl %edx,%edx
|
||||
movl %eax,4(%edi)
|
||||
|
||||
movl 8(%esi),%ebx
|
||||
movl 12(%esi),%eax
|
||||
adcl %ebx,%ebx
|
||||
movl %edx,8(%edi)
|
||||
adcl %eax,%eax
|
||||
movl %ebx,12(%edi)
|
||||
|
||||
movl 16(%esi),%edx
|
||||
movl 20(%esi),%ebx
|
||||
adcl %edx,%edx
|
||||
movl %eax,16(%edi)
|
||||
adcl %ebx,%ebx
|
||||
movl %edx,20(%edi)
|
||||
|
||||
movl 24(%esi),%eax
|
||||
movl 28(%esi),%edx
|
||||
adcl %eax,%eax
|
||||
movl %ebx,24(%edi)
|
||||
adcl %edx,%edx
|
||||
movl %eax,28(%edi)
|
||||
|
||||
leal 32(%esi),%esi /* use leal not to clobber carry */
|
||||
leal 32(%edi),%edi
|
||||
decl %ebp
|
||||
jnz LLoop
|
||||
|
||||
LLend: popl %ebp
|
||||
sbbl %eax,%eax /* save carry in %eax */
|
||||
andl $7,%ebp
|
||||
jz LLend2
|
||||
addl %eax,%eax /* restore carry from eax */
|
||||
LLoop2: movl %edx,%ebx
|
||||
movl (%esi),%edx
|
||||
adcl %edx,%edx
|
||||
movl %ebx,(%edi)
|
||||
|
||||
leal 4(%esi),%esi /* use leal not to clobber carry */
|
||||
leal 4(%edi),%edi
|
||||
decl %ebp
|
||||
jnz LLoop2
|
||||
|
||||
jmp LL1
|
||||
LLend2: addl %eax,%eax /* restore carry from eax */
|
||||
LL1: movl %edx,(%edi) /* store last limb */
|
||||
|
||||
sbbl %eax,%eax
|
||||
negl %eax
|
||||
|
||||
popl %ebp
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
@ -1,5 +1,6 @@
|
||||
syntax.h
|
||||
mpih-shift.S
|
||||
mpih-lshift.S
|
||||
mpih-rshift.S
|
||||
mpih-add1.S
|
||||
mpih-sub1.S
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
/* mc68020 __mpn_lshift -- Shift left a low-level natural-number integer.
|
||||
/* mc68020 lshift -- Shift left a low-level natural-number integer.
|
||||
|
||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
This file is part of GNUPG.
|
||||
|
||||
The GNU MP Library is free software; you can redistribute it and/or modify
|
||||
GNUPG is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Library General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
GNUPG is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
|
||||
License for more details.
|
||||
@ -17,7 +17,8 @@ License for more details.
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
MA 02111-1307, USA. */
|
||||
MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
@ -154,133 +155,4 @@ EPILOG(mpihelp_lshift)
|
||||
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* mpihelp_rshift( mpi_ptr_t wp, (sp + 4)
|
||||
* mpi_ptr_t up, (sp + 8)
|
||||
* mpi_size_t usize, (sp + 12)
|
||||
* unsigned cnt) (sp + 16)
|
||||
*/
|
||||
|
||||
#define res_ptr a1
|
||||
#define s_ptr a0
|
||||
#define s_size d6
|
||||
#define cnt d4
|
||||
|
||||
TEXT
|
||||
ALIGN
|
||||
GLOBL C_SYMBOL_NAME(mpihelp_rshift)
|
||||
|
||||
C_SYMBOL_NAME(mpihelp_rshift:)
|
||||
PROLOG(mpihelp_rshift)
|
||||
/* Save used registers on the stack. */
|
||||
moveml R(d2)-R(d6)/R(a2),MEM_PREDEC(sp)
|
||||
|
||||
/* Copy the arguments to registers. */
|
||||
movel MEM_DISP(sp,28),R(res_ptr)
|
||||
movel MEM_DISP(sp,32),R(s_ptr)
|
||||
movel MEM_DISP(sp,36),R(s_size)
|
||||
movel MEM_DISP(sp,40),R(cnt)
|
||||
|
||||
moveql #1,R(d5)
|
||||
cmpl R(d5),R(cnt)
|
||||
bne L(Rnormal)
|
||||
cmpl R(res_ptr),R(s_ptr)
|
||||
bls L(Rspecial) /* jump if res_ptr >= s_ptr */
|
||||
#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020))
|
||||
lea MEM_INDX1(res_ptr,s_size,l,4),R(a2)
|
||||
#else /* not mc68020 */
|
||||
movel R(s_size),R(d0)
|
||||
asll #2,R(d0)
|
||||
lea MEM_INDX(res_ptr,d0,l),R(a2)
|
||||
#endif
|
||||
cmpl R(s_ptr),R(a2)
|
||||
bls L(Rspecial) /* jump if s_ptr >= res_ptr + s_size */
|
||||
|
||||
L(Rnormal:)
|
||||
moveql #32,R(d5)
|
||||
subl R(cnt),R(d5)
|
||||
movel MEM_POSTINC(s_ptr),R(d2)
|
||||
movel R(d2),R(d0)
|
||||
lsll R(d5),R(d0) /* compute carry limb */
|
||||
|
||||
lsrl R(cnt),R(d2)
|
||||
movel R(d2),R(d1)
|
||||
subql #1,R(s_size)
|
||||
beq L(Rend)
|
||||
lsrl #1,R(s_size)
|
||||
bcs L(R1)
|
||||
subql #1,R(s_size)
|
||||
|
||||
L(Roop:)
|
||||
movel MEM_POSTINC(s_ptr),R(d2)
|
||||
movel R(d2),R(d3)
|
||||
lsll R(d5),R(d3)
|
||||
orl R(d3),R(d1)
|
||||
movel R(d1),MEM_POSTINC(res_ptr)
|
||||
lsrl R(cnt),R(d2)
|
||||
L(R1:)
|
||||
movel MEM_POSTINC(s_ptr),R(d1)
|
||||
movel R(d1),R(d3)
|
||||
lsll R(d5),R(d3)
|
||||
orl R(d3),R(d2)
|
||||
movel R(d2),MEM_POSTINC(res_ptr)
|
||||
lsrl R(cnt),R(d1)
|
||||
|
||||
dbf R(s_size),L(Roop)
|
||||
subl #0x10000,R(s_size)
|
||||
bcc L(Roop)
|
||||
|
||||
L(Rend:)
|
||||
movel R(d1),MEM(res_ptr) /* store most significant limb */
|
||||
|
||||
/* Restore used registers from stack frame. */
|
||||
moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2)
|
||||
rts
|
||||
|
||||
/* We loop from most significant end of the arrays, which is only
|
||||
permissable if the source and destination don't overlap, since the
|
||||
function is documented to work for overlapping source and destination. */
|
||||
|
||||
L(Rspecial:)
|
||||
#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020))
|
||||
lea MEM_INDX1(s_ptr,s_size,l,4),R(s_ptr)
|
||||
lea MEM_INDX1(res_ptr,s_size,l,4),R(res_ptr)
|
||||
#else /* not mc68000 */
|
||||
movel R(s_size),R(d0)
|
||||
asll #2,R(d0)
|
||||
addl R(s_size),R(s_ptr)
|
||||
addl R(s_size),R(res_ptr)
|
||||
#endif
|
||||
|
||||
clrl R(d0) /* initialize carry */
|
||||
eorw #1,R(s_size)
|
||||
lsrl #1,R(s_size)
|
||||
bcc L(LR1)
|
||||
subql #1,R(s_size)
|
||||
|
||||
L(LRoop:)
|
||||
movel MEM_PREDEC(s_ptr),R(d2)
|
||||
roxrl #1,R(d2)
|
||||
movel R(d2),MEM_PREDEC(res_ptr)
|
||||
L(LR1:)
|
||||
movel MEM_PREDEC(s_ptr),R(d2)
|
||||
roxrl #1,R(d2)
|
||||
movel R(d2),MEM_PREDEC(res_ptr)
|
||||
|
||||
dbf R(s_size),L(LRoop)
|
||||
roxrl #1,R(d0) /* save cy in msb */
|
||||
subl #0x10000,R(s_size)
|
||||
bcs L(LRend)
|
||||
addl R(d0),R(d0) /* restore cy */
|
||||
bra L(LRoop)
|
||||
|
||||
L(LRend:)
|
||||
/* Restore used registers from stack frame. */
|
||||
moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2)
|
||||
rts
|
||||
EPILOG(mpihelp_rshift)
|
||||
|
||||
|
||||
|
||||
|
156
mpi/m68k/mpih-rshift.S
Normal file
156
mpi/m68k/mpih-rshift.S
Normal file
@ -0,0 +1,156 @@
|
||||
/* mc68020 rshift -- Shift right a low-level natural-number integer.
|
||||
|
||||
Copyright (C) 1996, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNUPG.
|
||||
|
||||
GNUPG is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Library General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
GNUPG is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* mpihelp_rshift( mpi_ptr_t wp, (sp + 4)
|
||||
* mpi_ptr_t up, (sp + 8)
|
||||
* mpi_size_t usize, (sp + 12)
|
||||
* unsigned cnt) (sp + 16)
|
||||
*/
|
||||
|
||||
#define res_ptr a1
|
||||
#define s_ptr a0
|
||||
#define s_size d6
|
||||
#define cnt d4
|
||||
|
||||
TEXT
|
||||
ALIGN
|
||||
GLOBL C_SYMBOL_NAME(mpihelp_rshift)
|
||||
|
||||
C_SYMBOL_NAME(mpihelp_rshift:)
|
||||
PROLOG(mpihelp_rshift)
|
||||
/* Save used registers on the stack. */
|
||||
moveml R(d2)-R(d6)/R(a2),MEM_PREDEC(sp)
|
||||
|
||||
/* Copy the arguments to registers. */
|
||||
movel MEM_DISP(sp,28),R(res_ptr)
|
||||
movel MEM_DISP(sp,32),R(s_ptr)
|
||||
movel MEM_DISP(sp,36),R(s_size)
|
||||
movel MEM_DISP(sp,40),R(cnt)
|
||||
|
||||
moveql #1,R(d5)
|
||||
cmpl R(d5),R(cnt)
|
||||
bne L(Rnormal)
|
||||
cmpl R(res_ptr),R(s_ptr)
|
||||
bls L(Rspecial) /* jump if res_ptr >= s_ptr */
|
||||
#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020))
|
||||
lea MEM_INDX1(res_ptr,s_size,l,4),R(a2)
|
||||
#else /* not mc68020 */
|
||||
movel R(s_size),R(d0)
|
||||
asll #2,R(d0)
|
||||
lea MEM_INDX(res_ptr,d0,l),R(a2)
|
||||
#endif
|
||||
cmpl R(s_ptr),R(a2)
|
||||
bls L(Rspecial) /* jump if s_ptr >= res_ptr + s_size */
|
||||
|
||||
L(Rnormal:)
|
||||
moveql #32,R(d5)
|
||||
subl R(cnt),R(d5)
|
||||
movel MEM_POSTINC(s_ptr),R(d2)
|
||||
movel R(d2),R(d0)
|
||||
lsll R(d5),R(d0) /* compute carry limb */
|
||||
|
||||
lsrl R(cnt),R(d2)
|
||||
movel R(d2),R(d1)
|
||||
subql #1,R(s_size)
|
||||
beq L(Rend)
|
||||
lsrl #1,R(s_size)
|
||||
bcs L(R1)
|
||||
subql #1,R(s_size)
|
||||
|
||||
L(Roop:)
|
||||
movel MEM_POSTINC(s_ptr),R(d2)
|
||||
movel R(d2),R(d3)
|
||||
lsll R(d5),R(d3)
|
||||
orl R(d3),R(d1)
|
||||
movel R(d1),MEM_POSTINC(res_ptr)
|
||||
lsrl R(cnt),R(d2)
|
||||
L(R1:)
|
||||
movel MEM_POSTINC(s_ptr),R(d1)
|
||||
movel R(d1),R(d3)
|
||||
lsll R(d5),R(d3)
|
||||
orl R(d3),R(d2)
|
||||
movel R(d2),MEM_POSTINC(res_ptr)
|
||||
lsrl R(cnt),R(d1)
|
||||
|
||||
dbf R(s_size),L(Roop)
|
||||
subl #0x10000,R(s_size)
|
||||
bcc L(Roop)
|
||||
|
||||
L(Rend:)
|
||||
movel R(d1),MEM(res_ptr) /* store most significant limb */
|
||||
|
||||
/* Restore used registers from stack frame. */
|
||||
moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2)
|
||||
rts
|
||||
|
||||
/* We loop from most significant end of the arrays, which is only
|
||||
permissable if the source and destination don't overlap, since the
|
||||
function is documented to work for overlapping source and destination. */
|
||||
|
||||
L(Rspecial:)
|
||||
#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020))
|
||||
lea MEM_INDX1(s_ptr,s_size,l,4),R(s_ptr)
|
||||
lea MEM_INDX1(res_ptr,s_size,l,4),R(res_ptr)
|
||||
#else /* not mc68000 */
|
||||
movel R(s_size),R(d0)
|
||||
asll #2,R(d0)
|
||||
addl R(s_size),R(s_ptr)
|
||||
addl R(s_size),R(res_ptr)
|
||||
#endif
|
||||
|
||||
clrl R(d0) /* initialize carry */
|
||||
eorw #1,R(s_size)
|
||||
lsrl #1,R(s_size)
|
||||
bcc L(LR1)
|
||||
subql #1,R(s_size)
|
||||
|
||||
L(LRoop:)
|
||||
movel MEM_PREDEC(s_ptr),R(d2)
|
||||
roxrl #1,R(d2)
|
||||
movel R(d2),MEM_PREDEC(res_ptr)
|
||||
L(LR1:)
|
||||
movel MEM_PREDEC(s_ptr),R(d2)
|
||||
roxrl #1,R(d2)
|
||||
movel R(d2),MEM_PREDEC(res_ptr)
|
||||
|
||||
dbf R(s_size),L(LRoop)
|
||||
roxrl #1,R(d0) /* save cy in msb */
|
||||
subl #0x10000,R(s_size)
|
||||
bcs L(LRend)
|
||||
addl R(d0),R(d0) /* restore cy */
|
||||
bra L(LRoop)
|
||||
|
||||
L(LRend:)
|
||||
/* Restore used registers from stack frame. */
|
||||
moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2)
|
||||
rts
|
||||
EPILOG(mpihelp_rshift)
|
||||
|
||||
|
||||
|
||||
|
@ -1,2 +1,3 @@
|
||||
mpih-shift.S
|
||||
mpih-lshift.S
|
||||
mpih-rshift.S
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* hppa rshift, lshift
|
||||
/* hppa lshift
|
||||
* optimized for the PA7100, where is runs at 3.25 cycles/limb
|
||||
* Copyright (C) 1992, 1994 Free Software Foundation, Inc.
|
||||
* Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
@ -18,14 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
* way the data is stored; this is to support the abstraction
|
||||
* of an optional secure memory allocation which may be used
|
||||
* to avoid revealing of sensitive data due to paging etc.
|
||||
* The GNU MP Library itself is published under the LGPL;
|
||||
* however I decided to publish this code under the plain GPL.
|
||||
*/
|
||||
|
||||
|
||||
@ -95,64 +87,3 @@ L$0004 vshd %r22,%r0,%r20
|
||||
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* mpihelp_rshift( mpi_ptr_t wp, (gr26)
|
||||
* mpi_ptr_t up, (gr25)
|
||||
* mpi_size_t usize, (gr24)
|
||||
* unsigned cnt) (gr23)
|
||||
*/
|
||||
|
||||
.code
|
||||
.export mpihelp_rshift
|
||||
mpihelp_rshift
|
||||
.proc
|
||||
.callinfo frame=64,no_calls
|
||||
.entry
|
||||
|
||||
ldws,ma 4(0,%r25),%r22
|
||||
mtsar %r23
|
||||
addib,= -1,%r24,L$r004
|
||||
vshd %r22,%r0,%r28 ; compute carry out limb
|
||||
ldws,ma 4(0,%r25),%r29
|
||||
addib,<= -5,%r24,L$rrest
|
||||
vshd %r29,%r22,%r20
|
||||
|
||||
L$roop ldws,ma 4(0,%r25),%r22
|
||||
stws,ma %r20,4(0,%r26)
|
||||
vshd %r22,%r29,%r20
|
||||
ldws,ma 4(0,%r25),%r29
|
||||
stws,ma %r20,4(0,%r26)
|
||||
vshd %r29,%r22,%r20
|
||||
ldws,ma 4(0,%r25),%r22
|
||||
stws,ma %r20,4(0,%r26)
|
||||
vshd %r22,%r29,%r20
|
||||
ldws,ma 4(0,%r25),%r29
|
||||
stws,ma %r20,4(0,%r26)
|
||||
addib,> -4,%r24,L$roop
|
||||
vshd %r29,%r22,%r20
|
||||
|
||||
L$rrest addib,= 4,%r24,L$rend1
|
||||
nop
|
||||
L$eroop ldws,ma 4(0,%r25),%r22
|
||||
stws,ma %r20,4(0,%r26)
|
||||
addib,<= -1,%r24,L$rend2
|
||||
vshd %r22,%r29,%r20
|
||||
ldws,ma 4(0,%r25),%r29
|
||||
stws,ma %r20,4(0,%r26)
|
||||
addib,> -1,%r24,L$eroop
|
||||
vshd %r29,%r22,%r20
|
||||
|
||||
L$rend1 stws,ma %r20,4(0,%r26)
|
||||
vshd %r0,%r29,%r20
|
||||
bv 0(%r2)
|
||||
stw %r20,0(0,%r26)
|
||||
L$rend2 stws,ma %r20,4(0,%r26)
|
||||
L$r004 vshd %r0,%r22,%r20
|
||||
bv 0(%r2)
|
||||
stw %r20,0(0,%r26)
|
||||
|
||||
.exit
|
||||
.procend
|
||||
|
||||
|
85
mpi/pa7100/mpih-rshift.S
Normal file
85
mpi/pa7100/mpih-rshift.S
Normal file
@ -0,0 +1,85 @@
|
||||
/* hppa rshift
|
||||
* optimized for the PA7100, where is runs at 3.25 cycles/limb
|
||||
* Copyright (C) 1992, 1994 Free Software Foundation, Inc.
|
||||
* Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNUPG.
|
||||
*
|
||||
* GNUPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GNUPG is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* mpihelp_rshift( mpi_ptr_t wp, (gr26)
|
||||
* mpi_ptr_t up, (gr25)
|
||||
* mpi_size_t usize, (gr24)
|
||||
* unsigned cnt) (gr23)
|
||||
*/
|
||||
|
||||
.code
|
||||
.export mpihelp_rshift
|
||||
mpihelp_rshift
|
||||
.proc
|
||||
.callinfo frame=64,no_calls
|
||||
.entry
|
||||
|
||||
ldws,ma 4(0,%r25),%r22
|
||||
mtsar %r23
|
||||
addib,= -1,%r24,L$r004
|
||||
vshd %r22,%r0,%r28 ; compute carry out limb
|
||||
ldws,ma 4(0,%r25),%r29
|
||||
addib,<= -5,%r24,L$rrest
|
||||
vshd %r29,%r22,%r20
|
||||
|
||||
L$roop ldws,ma 4(0,%r25),%r22
|
||||
stws,ma %r20,4(0,%r26)
|
||||
vshd %r22,%r29,%r20
|
||||
ldws,ma 4(0,%r25),%r29
|
||||
stws,ma %r20,4(0,%r26)
|
||||
vshd %r29,%r22,%r20
|
||||
ldws,ma 4(0,%r25),%r22
|
||||
stws,ma %r20,4(0,%r26)
|
||||
vshd %r22,%r29,%r20
|
||||
ldws,ma 4(0,%r25),%r29
|
||||
stws,ma %r20,4(0,%r26)
|
||||
addib,> -4,%r24,L$roop
|
||||
vshd %r29,%r22,%r20
|
||||
|
||||
L$rrest addib,= 4,%r24,L$rend1
|
||||
nop
|
||||
L$eroop ldws,ma 4(0,%r25),%r22
|
||||
stws,ma %r20,4(0,%r26)
|
||||
addib,<= -1,%r24,L$rend2
|
||||
vshd %r22,%r29,%r20
|
||||
ldws,ma 4(0,%r25),%r29
|
||||
stws,ma %r20,4(0,%r26)
|
||||
addib,> -1,%r24,L$eroop
|
||||
vshd %r29,%r22,%r20
|
||||
|
||||
L$rend1 stws,ma %r20,4(0,%r26)
|
||||
vshd %r0,%r29,%r20
|
||||
bv 0(%r2)
|
||||
stw %r20,0(0,%r26)
|
||||
L$rend2 stws,ma %r20,4(0,%r26)
|
||||
L$r004 vshd %r0,%r22,%r20
|
||||
bv 0(%r2)
|
||||
stw %r20,0(0,%r26)
|
||||
|
||||
.exit
|
||||
.procend
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
|
||||
mpih-lshift.S
|
||||
mpih-rshift.S
|
||||
mpih-add1.S
|
||||
udiv.S
|
||||
|
||||
|
@ -1,24 +1,25 @@
|
||||
! SPARC __mpn_add_n -- Add two limb vectors of the same length > 0 and store
|
||||
! sum in a third limb vector.
|
||||
/* SPARC _add_n -- Add two limb vectors of the same length > 0 and store
|
||||
* sum in a third limb vector.
|
||||
*
|
||||
* Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNUPG.
|
||||
*
|
||||
* GNUPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GNUPG is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
! Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
||||
|
||||
! This file is part of the GNU MP Library.
|
||||
|
||||
! The GNU MP Library is free software; you can redistribute it and/or modify
|
||||
! it under the terms of the GNU Library General Public License as published by
|
||||
! the Free Software Foundation; either version 2 of the License, or (at your
|
||||
! option) any later version.
|
||||
|
||||
! The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
! WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
! or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
|
||||
! License for more details.
|
||||
|
||||
! You should have received a copy of the GNU Library General Public License
|
||||
! along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
! the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
! MA 02111-1307, USA.
|
||||
|
||||
|
||||
/*******************
|
||||
|
96
mpi/sparc32/mpih-lshift.S
Normal file
96
mpi/sparc32/mpih-lshift.S
Normal file
@ -0,0 +1,96 @@
|
||||
/* sparc lshift
|
||||
*
|
||||
* Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNUPG.
|
||||
*
|
||||
* GNUPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GNUPG is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
! INPUT PARAMETERS
|
||||
! res_ptr %o0
|
||||
! src_ptr %o1
|
||||
! size %o2
|
||||
! cnt %o3
|
||||
|
||||
#include "sysdep.h"
|
||||
|
||||
.text
|
||||
.align 4
|
||||
.global C_SYMBOL_NAME(mpihelp_lshift)
|
||||
C_SYMBOL_NAME(mpihelp_lshift):
|
||||
sll %o2,2,%g1
|
||||
add %o1,%g1,%o1 ! make %o1 point at end of src
|
||||
ld [%o1-4],%g2 ! load first limb
|
||||
sub %g0,%o3,%o5 ! negate shift count
|
||||
add %o0,%g1,%o0 ! make %o0 point at end of res
|
||||
add %o2,-1,%o2
|
||||
andcc %o2,4-1,%g4 ! number of limbs in first loop
|
||||
srl %g2,%o5,%g1 ! compute function result
|
||||
be L0 ! if multiple of 4 limbs, skip first loop
|
||||
st %g1,[%sp+80]
|
||||
|
||||
sub %o2,%g4,%o2 ! adjust count for main loop
|
||||
|
||||
Loop0: ld [%o1-8],%g3
|
||||
add %o0,-4,%o0
|
||||
add %o1,-4,%o1
|
||||
addcc %g4,-1,%g4
|
||||
sll %g2,%o3,%o4
|
||||
srl %g3,%o5,%g1
|
||||
mov %g3,%g2
|
||||
or %o4,%g1,%o4
|
||||
bne Loop0
|
||||
st %o4,[%o0+0]
|
||||
|
||||
L0: tst %o2
|
||||
be Lend
|
||||
nop
|
||||
|
||||
Loop: ld [%o1-8],%g3
|
||||
add %o0,-16,%o0
|
||||
addcc %o2,-4,%o2
|
||||
sll %g2,%o3,%o4
|
||||
srl %g3,%o5,%g1
|
||||
|
||||
ld [%o1-12],%g2
|
||||
sll %g3,%o3,%g4
|
||||
or %o4,%g1,%o4
|
||||
st %o4,[%o0+12]
|
||||
srl %g2,%o5,%g1
|
||||
|
||||
ld [%o1-16],%g3
|
||||
sll %g2,%o3,%o4
|
||||
or %g4,%g1,%g4
|
||||
st %g4,[%o0+8]
|
||||
srl %g3,%o5,%g1
|
||||
|
||||
ld [%o1-20],%g2
|
||||
sll %g3,%o3,%g4
|
||||
or %o4,%g1,%o4
|
||||
st %o4,[%o0+4]
|
||||
srl %g2,%o5,%g1
|
||||
|
||||
add %o1,-16,%o1
|
||||
or %g4,%g1,%g4
|
||||
bne Loop
|
||||
st %g4,[%o0+0]
|
||||
|
||||
Lend: sll %g2,%o3,%g2
|
||||
st %g2,[%o0-4]
|
||||
retl
|
||||
ld [%sp+80],%o0
|
||||
|
92
mpi/sparc32/mpih-rshift.S
Normal file
92
mpi/sparc32/mpih-rshift.S
Normal file
@ -0,0 +1,92 @@
|
||||
/* sparc rshift
|
||||
*
|
||||
* Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNUPG.
|
||||
*
|
||||
* GNUPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GNUPG is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
! INPUT PARAMETERS
|
||||
! res_ptr %o0
|
||||
! src_ptr %o1
|
||||
! size %o2
|
||||
! cnt %o3
|
||||
|
||||
#include "sysdep.h"
|
||||
|
||||
.text
|
||||
.align 4
|
||||
.global C_SYMBOL_NAME(mpohelp_rshift)
|
||||
C_SYMBOL_NAME(mpihelp_rshift):
|
||||
ld [%o1],%g2 ! load first limb
|
||||
sub %g0,%o3,%o5 ! negate shift count
|
||||
add %o2,-1,%o2
|
||||
andcc %o2,4-1,%g4 ! number of limbs in first loop
|
||||
sll %g2,%o5,%g1 ! compute function result
|
||||
be L0 ! if multiple of 4 limbs, skip first loop
|
||||
st %g1,[%sp+80]
|
||||
|
||||
sub %o2,%g4,%o2 ! adjust count for main loop
|
||||
|
||||
Loop0: ld [%o1+4],%g3
|
||||
add %o0,4,%o0
|
||||
add %o1,4,%o1
|
||||
addcc %g4,-1,%g4
|
||||
srl %g2,%o3,%o4
|
||||
sll %g3,%o5,%g1
|
||||
mov %g3,%g2
|
||||
or %o4,%g1,%o4
|
||||
bne Loop0
|
||||
st %o4,[%o0-4]
|
||||
|
||||
L0: tst %o2
|
||||
be Lend
|
||||
nop
|
||||
|
||||
Loop: ld [%o1+4],%g3
|
||||
add %o0,16,%o0
|
||||
addcc %o2,-4,%o2
|
||||
srl %g2,%o3,%o4
|
||||
sll %g3,%o5,%g1
|
||||
|
||||
ld [%o1+8],%g2
|
||||
srl %g3,%o3,%g4
|
||||
or %o4,%g1,%o4
|
||||
st %o4,[%o0-16]
|
||||
sll %g2,%o5,%g1
|
||||
|
||||
ld [%o1+12],%g3
|
||||
srl %g2,%o3,%o4
|
||||
or %g4,%g1,%g4
|
||||
st %g4,[%o0-12]
|
||||
sll %g3,%o5,%g1
|
||||
|
||||
ld [%o1+16],%g2
|
||||
srl %g3,%o3,%g4
|
||||
or %o4,%g1,%o4
|
||||
st %o4,[%o0-8]
|
||||
sll %g2,%o5,%g1
|
||||
|
||||
add %o1,16,%o1
|
||||
or %g4,%g1,%g4
|
||||
bne Loop
|
||||
st %g4,[%o0-4]
|
||||
|
||||
Lend: srl %g2,%o3,%g2
|
||||
st %g2,[%o0-0]
|
||||
retl
|
||||
ld [%sp+80],%o0
|
||||
|
@ -1,3 +1,7 @@
|
||||
Mon May 18 15:39:22 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* mk-tdata.c: New.
|
||||
|
||||
Tue Apr 7 19:50:41 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
|
||||
* bftest.c: Now supports all availabe ciphers.
|
||||
|
@ -4,13 +4,14 @@ INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/intl -I../intl
|
||||
needed_libs = ../cipher/libcipher.a ../util/libutil.a \
|
||||
../mpi/libmpi.a ../util/libutil.a
|
||||
|
||||
noinst_PROGRAMS = mpicalc bftest clean-sat
|
||||
noinst_PROGRAMS = mpicalc bftest clean-sat mk-tdata
|
||||
|
||||
mpicalc_SOURCES = mpicalc.c
|
||||
|
||||
bftest_SOURCES = bftest.c
|
||||
|
||||
clean_sat_SOURCES = clean-sat.c
|
||||
mk_tdata_SOURCES = mk-tdata.c
|
||||
|
||||
|
||||
mpicalc_LDADD = @INTLLIBS@ $(needed_libs)
|
||||
|
@ -96,13 +96,14 @@ INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/intl -I../intl
|
||||
needed_libs = ../cipher/libcipher.a ../util/libutil.a \
|
||||
../mpi/libmpi.a ../util/libutil.a
|
||||
|
||||
noinst_PROGRAMS = mpicalc bftest clean-sat
|
||||
noinst_PROGRAMS = mpicalc bftest clean-sat mk-tdata
|
||||
|
||||
mpicalc_SOURCES = mpicalc.c
|
||||
|
||||
bftest_SOURCES = bftest.c
|
||||
|
||||
clean_sat_SOURCES = clean-sat.c
|
||||
mk_tdata_SOURCES = mk-tdata.c
|
||||
|
||||
mpicalc_LDADD = @INTLLIBS@ $(needed_libs)
|
||||
bftest_LDADD = @INTLLIBS@ $(needed_libs)
|
||||
@ -128,6 +129,10 @@ clean_sat_OBJECTS = clean-sat.o
|
||||
clean_sat_LDADD = $(LDADD)
|
||||
clean_sat_DEPENDENCIES =
|
||||
clean_sat_LDFLAGS =
|
||||
mk_tdata_OBJECTS = mk-tdata.o
|
||||
mk_tdata_LDADD = $(LDADD)
|
||||
mk_tdata_DEPENDENCIES =
|
||||
mk_tdata_LDFLAGS =
|
||||
CFLAGS = @CFLAGS@
|
||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
|
||||
LINK = $(CC) $(CFLAGS) $(LDFLAGS) -o $@
|
||||
@ -138,9 +143,10 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = tar
|
||||
GZIP = --best
|
||||
DEP_FILES = .deps/bftest.P .deps/clean-sat.P .deps/mpicalc.P
|
||||
SOURCES = $(mpicalc_SOURCES) $(bftest_SOURCES) $(clean_sat_SOURCES)
|
||||
OBJECTS = $(mpicalc_OBJECTS) $(bftest_OBJECTS) $(clean_sat_OBJECTS)
|
||||
DEP_FILES = .deps/bftest.P .deps/clean-sat.P .deps/mk-tdata.P \
|
||||
.deps/mpicalc.P
|
||||
SOURCES = $(mpicalc_SOURCES) $(bftest_SOURCES) $(clean_sat_SOURCES) $(mk_tdata_SOURCES)
|
||||
OBJECTS = $(mpicalc_OBJECTS) $(bftest_OBJECTS) $(clean_sat_OBJECTS) $(mk_tdata_OBJECTS)
|
||||
|
||||
default: all
|
||||
|
||||
@ -191,6 +197,10 @@ clean-sat: $(clean_sat_OBJECTS) $(clean_sat_DEPENDENCIES)
|
||||
@rm -f clean-sat
|
||||
$(LINK) $(clean_sat_LDFLAGS) $(clean_sat_OBJECTS) $(clean_sat_LDADD) $(LIBS)
|
||||
|
||||
mk-tdata: $(mk_tdata_OBJECTS) $(mk_tdata_DEPENDENCIES)
|
||||
@rm -f mk-tdata
|
||||
$(LINK) $(mk_tdata_LDFLAGS) $(mk_tdata_OBJECTS) $(mk_tdata_LDADD) $(LIBS)
|
||||
|
||||
tags: TAGS
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP)
|
||||
|
BIN
tools/mk-tdata
Executable file
BIN
tools/mk-tdata
Executable file
Binary file not shown.
@ -93,7 +93,7 @@ POSUB = po
|
||||
RANLIB = ranlib
|
||||
USE_INCLUDED_LIBINTL = yes
|
||||
USE_NLS = yes
|
||||
VERSION = 0.2.18
|
||||
VERSION = 0.2.18a
|
||||
ZLIBS =
|
||||
l =
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user