|
|
|
@ -843,17 +843,37 @@ pgp_write_sig(pgp_output_t *output,
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* add a time stamp to the output */
|
|
|
|
|
unsigned
|
|
|
|
|
pgp_add_time(pgp_create_sig_t *sig, int64_t when, const char *type)
|
|
|
|
|
pgp_add_creation_time(pgp_create_sig_t *sig, uint64_t when)
|
|
|
|
|
{
|
|
|
|
|
pgp_content_enum tag;
|
|
|
|
|
|
|
|
|
|
tag = (strcmp(type, "birth") == 0) ?
|
|
|
|
|
PGP_PTAG_SS_CREATION_TIME : PGP_PTAG_SS_EXPIRATION_TIME;
|
|
|
|
|
/* just do 32-bit timestamps for just now - it's in the protocol */
|
|
|
|
|
tag = PGP_PTAG_SS_CREATION_TIME;
|
|
|
|
|
|
|
|
|
|
return pgp_write_ss_header(sig->output, 5, tag) &&
|
|
|
|
|
pgp_write_scalar(sig->output, when, 4/*sizeof(when)*/);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned
|
|
|
|
|
pgp_add_sig_expiration_time(pgp_create_sig_t *sig, uint64_t duration)
|
|
|
|
|
{
|
|
|
|
|
pgp_content_enum tag;
|
|
|
|
|
|
|
|
|
|
tag = PGP_PTAG_SS_EXPIRATION_TIME;
|
|
|
|
|
|
|
|
|
|
return pgp_write_ss_header(sig->output, 5, tag) &&
|
|
|
|
|
pgp_write_scalar(sig->output, duration, 4/*sizeof(duration)*/);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned
|
|
|
|
|
pgp_add_key_expiration_time(pgp_create_sig_t *sig, uint64_t duration)
|
|
|
|
|
{
|
|
|
|
|
pgp_content_enum tag;
|
|
|
|
|
|
|
|
|
|
tag = PGP_PTAG_SS_KEY_EXPIRY;
|
|
|
|
|
|
|
|
|
|
return pgp_write_ss_header(sig->output, 5, tag) &&
|
|
|
|
|
pgp_write_scalar(sig->output, (uint32_t)when, (unsigned)sizeof(uint32_t));
|
|
|
|
|
pgp_write_scalar(sig->output, duration, 4/*sizeof(duration)*/);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -1031,8 +1051,8 @@ pgp_sign_file(pgp_io_t *io,
|
|
|
|
|
/* - creation time */
|
|
|
|
|
/* - key id */
|
|
|
|
|
ret = pgp_writer_use_armored_sig(output) &&
|
|
|
|
|
pgp_add_time(sig, (int64_t)from, "birth") &&
|
|
|
|
|
pgp_add_time(sig, (int64_t)duration, "expiration");
|
|
|
|
|
pgp_add_creation_time(sig, (uint64_t)from) &&
|
|
|
|
|
pgp_add_sig_expiration_time(sig, (uint64_t)duration);
|
|
|
|
|
if (ret == 0) {
|
|
|
|
|
pgp_teardown_file_write(output, fd_out);
|
|
|
|
|
return 0;
|
|
|
|
@ -1078,8 +1098,8 @@ pgp_sign_file(pgp_io_t *io,
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* add creation time to signature */
|
|
|
|
|
pgp_add_time(sig, (int64_t)from, "birth");
|
|
|
|
|
pgp_add_time(sig, (int64_t)duration, "expiration");
|
|
|
|
|
pgp_add_creation_time(sig, (uint64_t)from);
|
|
|
|
|
pgp_add_sig_expiration_time(sig, (uint64_t)duration);
|
|
|
|
|
/* add key id to signature */
|
|
|
|
|
pgp_keyid(keyid, PGP_KEY_ID_SIZE, &seckey->pubkey, hash_alg);
|
|
|
|
|
pgp_add_issuer_keyid(sig, keyid);
|
|
|
|
@ -1172,8 +1192,8 @@ pgp_sign_buf(pgp_io_t *io,
|
|
|
|
|
ret = pgp_writer_push_clearsigned(output, sig) &&
|
|
|
|
|
pgp_write(output, input, (unsigned)insize) &&
|
|
|
|
|
pgp_writer_use_armored_sig(output) &&
|
|
|
|
|
pgp_add_time(sig, from, "birth") &&
|
|
|
|
|
pgp_add_time(sig, (int64_t)duration, "expiration");
|
|
|
|
|
pgp_add_creation_time(sig, from) &&
|
|
|
|
|
pgp_add_sig_expiration_time(sig, (uint64_t)duration);
|
|
|
|
|
if (ret == 0) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
@ -1203,8 +1223,8 @@ pgp_sign_buf(pgp_io_t *io,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* add creation time to signature */
|
|
|
|
|
pgp_add_time(sig, from, "birth");
|
|
|
|
|
pgp_add_time(sig, (int64_t)duration, "expiration");
|
|
|
|
|
pgp_add_creation_time(sig, from);
|
|
|
|
|
pgp_add_sig_expiration_time(sig, (uint64_t)duration);
|
|
|
|
|
/* add key id to signature */
|
|
|
|
|
pgp_keyid(keyid, PGP_KEY_ID_SIZE, &seckey->pubkey, hash_alg);
|
|
|
|
|
pgp_add_issuer_keyid(sig, keyid);
|
|
|
|
@ -1271,8 +1291,8 @@ pgp_sign_detached(pgp_io_t *io,
|
|
|
|
|
pgp_memory_free(mem);
|
|
|
|
|
|
|
|
|
|
/* calculate the signature */
|
|
|
|
|
pgp_add_time(sig, from, "birth");
|
|
|
|
|
pgp_add_time(sig, (int64_t)duration, "expiration");
|
|
|
|
|
pgp_add_creation_time(sig, from);
|
|
|
|
|
pgp_add_sig_expiration_time(sig, (uint64_t)duration);
|
|
|
|
|
pgp_keyid(keyid, sizeof(keyid), &seckey->pubkey, hash_alg);
|
|
|
|
|
pgp_add_issuer_keyid(sig, keyid);
|
|
|
|
|
pgp_end_hashed_subpkts(sig);
|
|
|
|
|