add date parameter to generateKey function
This commit is contained in:
parent
afc9164e7d
commit
eb96d44298
|
@ -1154,7 +1154,7 @@ export function generate(options) {
|
|||
});
|
||||
|
||||
function generateSecretKey() {
|
||||
secretKeyPacket = new packet.SecretKey();
|
||||
secretKeyPacket = new packet.SecretKey(options.date);
|
||||
secretKeyPacket.packets = null;
|
||||
secretKeyPacket.algorithm = enums.read(enums.publicKey, options.keyType);
|
||||
options.curve = options.curve === enums.curve.curve25519 ? enums.curve.ed25519 : options.curve;
|
||||
|
@ -1162,7 +1162,7 @@ export function generate(options) {
|
|||
}
|
||||
|
||||
function generateSecretSubkey() {
|
||||
secretSubkeyPacket = new packet.SecretSubkey();
|
||||
secretSubkeyPacket = new packet.SecretSubkey(options.date);
|
||||
secretKeyPacket.packets = null;
|
||||
secretSubkeyPacket.algorithm = enums.read(enums.publicKey, options.subkeyType);
|
||||
options.curve = options.curve === enums.curve.ed25519 ? enums.curve.curve25519 : options.curve;
|
||||
|
@ -1245,7 +1245,7 @@ async function wrapKeyObject(secretKeyPacket, secretSubkeyPacket, options) {
|
|||
const dataToSign = {};
|
||||
dataToSign.userid = userIdPacket;
|
||||
dataToSign.key = secretKeyPacket;
|
||||
const signaturePacket = new packet.Signature();
|
||||
const signaturePacket = new packet.Signature(options.date);
|
||||
signaturePacket.signatureType = enums.signature.cert_generic;
|
||||
signaturePacket.publicKeyAlgorithm = options.keyType;
|
||||
signaturePacket.hashAlgorithm = await getPreferredHashAlgo(secretKeyPacket);
|
||||
|
@ -1290,7 +1290,7 @@ async function wrapKeyObject(secretKeyPacket, secretSubkeyPacket, options) {
|
|||
const dataToSign = {};
|
||||
dataToSign.key = secretKeyPacket;
|
||||
dataToSign.bind = secretSubkeyPacket;
|
||||
const subkeySignaturePacket = new packet.Signature();
|
||||
const subkeySignaturePacket = new packet.Signature(options.date);
|
||||
subkeySignaturePacket.signatureType = enums.signature.subkey_binding;
|
||||
subkeySignaturePacket.publicKeyAlgorithm = options.keyType;
|
||||
subkeySignaturePacket.hashAlgorithm = await getPreferredHashAlgo(secretSubkeyPacket);
|
||||
|
|
|
@ -111,11 +111,11 @@ export function destroyWorker() {
|
|||
*/
|
||||
|
||||
export function generateKey({
|
||||
userIds=[], passphrase, numBits=2048, unlocked=false, keyExpirationTime=0, curve=""
|
||||
userIds=[], passphrase, numBits=2048, unlocked=false, keyExpirationTime=0, curve="", date=new Date()
|
||||
} = {}) {
|
||||
userIds = formatUserIds(userIds);
|
||||
const options = {
|
||||
userIds, passphrase, numBits, unlocked, keyExpirationTime, curve
|
||||
userIds, passphrase, numBits, unlocked, keyExpirationTime, curve, date
|
||||
};
|
||||
|
||||
if (util.getWebCryptoAll() && numBits < 2048) {
|
||||
|
|
|
@ -42,7 +42,7 @@ import util from '../util';
|
|||
* @memberof module:packet
|
||||
* @constructor
|
||||
*/
|
||||
function PublicKey() {
|
||||
function PublicKey(date=new Date()) {
|
||||
/**
|
||||
* Packet type
|
||||
* @type {module:enums.packet}
|
||||
|
@ -57,7 +57,7 @@ function PublicKey() {
|
|||
* Key creation date.
|
||||
* @type {Date}
|
||||
*/
|
||||
this.created = util.normalizeDate();
|
||||
this.created = util.normalizeDate(date);
|
||||
/**
|
||||
* Algorithm specific params
|
||||
* @type {Array<Object>}
|
||||
|
|
|
@ -39,8 +39,8 @@ import util from '../util';
|
|||
* @constructor
|
||||
* @extends module:packet.PublicKey
|
||||
*/
|
||||
function SecretKey() {
|
||||
publicKey.call(this);
|
||||
function SecretKey(date=new Date()) {
|
||||
publicKey.call(this, date);
|
||||
/**
|
||||
* Packet type
|
||||
* @type {module:enums.packet}
|
||||
|
|
|
@ -30,8 +30,8 @@ import enums from '../enums';
|
|||
* @constructor
|
||||
* @extends module:packet.SecretKey
|
||||
*/
|
||||
function SecretSubkey() {
|
||||
secretKey.call(this);
|
||||
function SecretSubkey(date=new Date()) {
|
||||
secretKey.call(this, date);
|
||||
this.tag = enums.packet.secretSubkey;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user