mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-10 13:04:23 +01:00
* sign.c (mk_notation_and_policy): Include secret key to enable %s
expandos, and pass notations through pct_expando as well. * main.h, misc.c (pct_expando): Add %s and %S expandos for signer's keyid.
This commit is contained in:
parent
de2f0905b5
commit
8d5dad0ac3
@ -1,3 +1,11 @@
|
|||||||
|
2002-05-26 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
* sign.c (mk_notation_and_policy): Include secret key to enable %s
|
||||||
|
expandos, and pass notations through pct_expando as well.
|
||||||
|
|
||||||
|
* main.h, misc.c (pct_expando): Add %s and %S expandos for
|
||||||
|
signer's keyid.
|
||||||
|
|
||||||
2002-05-25 David Shaw <dshaw@jabberwocky.com>
|
2002-05-25 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* g10.c (strusage, build_list): Add compress algorithms to
|
* g10.c (strusage, build_list): Add compress algorithms to
|
||||||
|
@ -71,6 +71,7 @@ void idea_cipher_warn( int show );
|
|||||||
struct expando_args
|
struct expando_args
|
||||||
{
|
{
|
||||||
PKT_public_key *pk;
|
PKT_public_key *pk;
|
||||||
|
PKT_secret_key *sk;
|
||||||
byte imagetype;
|
byte imagetype;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
30
g10/misc.c
30
g10/misc.c
@ -455,11 +455,14 @@ pct_expando(const char *string,struct expando_args *args)
|
|||||||
{
|
{
|
||||||
const char *ch=string;
|
const char *ch=string;
|
||||||
int idx=0,maxlen=0,done=0;
|
int idx=0,maxlen=0,done=0;
|
||||||
u32 keyid[2]={0,0};
|
u32 pk_keyid[2]={0,0},sk_keyid[2]={0,0};
|
||||||
char *ret=NULL;
|
char *ret=NULL;
|
||||||
|
|
||||||
if(args->pk)
|
if(args->pk)
|
||||||
keyid_from_pk(args->pk,keyid);
|
keyid_from_pk(args->pk,pk_keyid);
|
||||||
|
|
||||||
|
if(args->sk)
|
||||||
|
keyid_from_sk(args->sk,sk_keyid);
|
||||||
|
|
||||||
while(*ch!='\0')
|
while(*ch!='\0')
|
||||||
{
|
{
|
||||||
@ -481,10 +484,29 @@ pct_expando(const char *string,struct expando_args *args)
|
|||||||
{
|
{
|
||||||
switch(*(ch+1))
|
switch(*(ch+1))
|
||||||
{
|
{
|
||||||
|
case 's': /* short key id */
|
||||||
|
if(idx+8<maxlen)
|
||||||
|
{
|
||||||
|
sprintf(&ret[idx],"%08lX",(ulong)sk_keyid[1]);
|
||||||
|
idx+=8;
|
||||||
|
done=1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'S': /* long key id */
|
||||||
|
if(idx+16<maxlen)
|
||||||
|
{
|
||||||
|
sprintf(&ret[idx],"%08lX%08lX",
|
||||||
|
(ulong)sk_keyid[0],(ulong)sk_keyid[1]);
|
||||||
|
idx+=16;
|
||||||
|
done=1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'k': /* short key id */
|
case 'k': /* short key id */
|
||||||
if(idx+8<maxlen)
|
if(idx+8<maxlen)
|
||||||
{
|
{
|
||||||
sprintf(&ret[idx],"%08lX",(ulong)keyid[1]);
|
sprintf(&ret[idx],"%08lX",(ulong)pk_keyid[1]);
|
||||||
idx+=8;
|
idx+=8;
|
||||||
done=1;
|
done=1;
|
||||||
}
|
}
|
||||||
@ -494,7 +516,7 @@ pct_expando(const char *string,struct expando_args *args)
|
|||||||
if(idx+16<maxlen)
|
if(idx+16<maxlen)
|
||||||
{
|
{
|
||||||
sprintf(&ret[idx],"%08lX%08lX",
|
sprintf(&ret[idx],"%08lX%08lX",
|
||||||
(ulong)keyid[0],(ulong)keyid[1]);
|
(ulong)pk_keyid[0],(ulong)pk_keyid[1]);
|
||||||
idx+=16;
|
idx+=16;
|
||||||
done=1;
|
done=1;
|
||||||
}
|
}
|
||||||
|
24
g10/sign.c
24
g10/sign.c
@ -55,7 +55,8 @@
|
|||||||
* NAME=VALUE format.
|
* NAME=VALUE format.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
mk_notation_and_policy( PKT_signature *sig, PKT_public_key *pk )
|
mk_notation_and_policy( PKT_signature *sig,
|
||||||
|
PKT_public_key *pk, PKT_secret_key *sk )
|
||||||
{
|
{
|
||||||
const char *string;
|
const char *string;
|
||||||
char *s=NULL;
|
char *s=NULL;
|
||||||
@ -66,6 +67,7 @@ mk_notation_and_policy( PKT_signature *sig, PKT_public_key *pk )
|
|||||||
|
|
||||||
memset(&args,0,sizeof(args));
|
memset(&args,0,sizeof(args));
|
||||||
args.pk=pk;
|
args.pk=pk;
|
||||||
|
args.sk=sk;
|
||||||
|
|
||||||
/* notation data */
|
/* notation data */
|
||||||
if(IS_SIG(sig) && opt.sig_notation_data)
|
if(IS_SIG(sig) && opt.sig_notation_data)
|
||||||
@ -84,13 +86,24 @@ mk_notation_and_policy( PKT_signature *sig, PKT_public_key *pk )
|
|||||||
}
|
}
|
||||||
|
|
||||||
for( ; nd; nd = nd->next ) {
|
for( ; nd; nd = nd->next ) {
|
||||||
|
char *expanded;
|
||||||
|
|
||||||
string = nd->d;
|
string = nd->d;
|
||||||
s = strchr( string, '=' );
|
s = strchr( string, '=' );
|
||||||
if( !s )
|
if( !s )
|
||||||
BUG(); /* we have already parsed this */
|
BUG(); /* we have already parsed this */
|
||||||
n1 = s - string;
|
n1 = s - string;
|
||||||
s++;
|
s++;
|
||||||
n2 = strlen(s);
|
|
||||||
|
expanded=pct_expando(s,&args);
|
||||||
|
if(!expanded)
|
||||||
|
{
|
||||||
|
log_error(_("WARNING: unable to %%-expand notation "
|
||||||
|
"(too large). Using unexpanded.\n"));
|
||||||
|
expanded=m_strdup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
n2 = strlen(expanded);
|
||||||
buf = m_alloc( 8 + n1 + n2 );
|
buf = m_alloc( 8 + n1 + n2 );
|
||||||
buf[0] = 0x80; /* human readable */
|
buf[0] = 0x80; /* human readable */
|
||||||
buf[1] = buf[2] = buf[3] = 0;
|
buf[1] = buf[2] = buf[3] = 0;
|
||||||
@ -99,10 +112,11 @@ mk_notation_and_policy( PKT_signature *sig, PKT_public_key *pk )
|
|||||||
buf[6] = n2 >> 8;
|
buf[6] = n2 >> 8;
|
||||||
buf[7] = n2;
|
buf[7] = n2;
|
||||||
memcpy(buf+8, string, n1 );
|
memcpy(buf+8, string, n1 );
|
||||||
memcpy(buf+8+n1, s, n2 );
|
memcpy(buf+8+n1, expanded, n2 );
|
||||||
build_sig_subpkt( sig, SIGSUBPKT_NOTATION
|
build_sig_subpkt( sig, SIGSUBPKT_NOTATION
|
||||||
| ((nd->flags & 1)? SIGSUBPKT_FLAG_CRITICAL:0),
|
| ((nd->flags & 1)? SIGSUBPKT_FLAG_CRITICAL:0),
|
||||||
buf, 8+n1+n2 );
|
buf, 8+n1+n2 );
|
||||||
|
m_free(expanded);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(opt.show_notation)
|
if(opt.show_notation)
|
||||||
@ -536,7 +550,7 @@ write_signature_packets (SK_LIST sk_list, IOBUF out, MD_HANDLE hash,
|
|||||||
|
|
||||||
if (sig->version >= 4)
|
if (sig->version >= 4)
|
||||||
build_sig_subpkt_from_sig (sig);
|
build_sig_subpkt_from_sig (sig);
|
||||||
mk_notation_and_policy (sig, NULL);
|
mk_notation_and_policy (sig, NULL, sk);
|
||||||
|
|
||||||
hash_sigversion_to_magic (md, sig);
|
hash_sigversion_to_magic (md, sig);
|
||||||
md_final (md);
|
md_final (md);
|
||||||
@ -1165,7 +1179,7 @@ make_keysig_packet( PKT_signature **ret_sig, PKT_public_key *pk,
|
|||||||
rc = (*mksubpkt)( sig, opaque );
|
rc = (*mksubpkt)( sig, opaque );
|
||||||
|
|
||||||
if( !rc ) {
|
if( !rc ) {
|
||||||
mk_notation_and_policy( sig, pk );
|
mk_notation_and_policy( sig, pk, sk );
|
||||||
hash_sigversion_to_magic (md, sig);
|
hash_sigversion_to_magic (md, sig);
|
||||||
md_final(md);
|
md_final(md);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user