mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2025-03-30 15:08:32 +00:00
Store unhashed subpackets in a more structured format (#1767)
To match the new `unknownSubpackets` property.
This commit is contained in:
parent
b1e27a1430
commit
9f5ff66c3d
9
openpgp.d.ts
vendored
9
openpgp.d.ts
vendored
@ -497,7 +497,8 @@ export class SignaturePacket extends BasePacket {
|
||||
public hashAlgorithm: enums.hash | null;
|
||||
public publicKeyAlgorithm: enums.publicKey | null;
|
||||
public signatureData: null | Uint8Array;
|
||||
public unhashedSubpackets: null | Uint8Array;
|
||||
public unhashedSubpackets: RawSubpacket[];
|
||||
public unknownSubpackets: RawSubpacket[];
|
||||
public signedHashValue: null | Uint8Array;
|
||||
public created: Date | null;
|
||||
public signatureExpirationTime: null | number;
|
||||
@ -541,6 +542,12 @@ export class SignaturePacket extends BasePacket {
|
||||
public getExpirationTime(): Date | typeof Infinity;
|
||||
}
|
||||
|
||||
export interface RawSubpacket {
|
||||
type: number;
|
||||
critical: boolean;
|
||||
body: Uint8Array;
|
||||
}
|
||||
|
||||
export interface RawNotation {
|
||||
name: string;
|
||||
value: Uint8Array;
|
||||
|
@ -396,10 +396,8 @@ class SignaturePacket {
|
||||
* @returns {Uint8Array} Subpacket data.
|
||||
*/
|
||||
writeUnhashedSubPackets() {
|
||||
const arr = [];
|
||||
this.unhashedSubpackets.forEach(data => {
|
||||
arr.push(writeSimpleLength(data.length));
|
||||
arr.push(data);
|
||||
const arr = this.unhashedSubpackets.map(({ type, critical, body }) => {
|
||||
return writeSubPacket(type, critical, body);
|
||||
});
|
||||
|
||||
const result = util.concat(arr);
|
||||
@ -408,7 +406,7 @@ class SignaturePacket {
|
||||
return util.concat([length, result]);
|
||||
}
|
||||
|
||||
// V4 signature sub packets
|
||||
// Signature subpackets
|
||||
readSubPacket(bytes, hashed = true) {
|
||||
let mypos = 0;
|
||||
|
||||
@ -416,15 +414,19 @@ class SignaturePacket {
|
||||
const critical = !!(bytes[mypos] & 0x80);
|
||||
const type = bytes[mypos] & 0x7F;
|
||||
|
||||
mypos++;
|
||||
|
||||
if (!hashed) {
|
||||
this.unhashedSubpackets.push(bytes.subarray(mypos, bytes.length));
|
||||
this.unhashedSubpackets.push({
|
||||
type,
|
||||
critical,
|
||||
body: bytes.subarray(mypos, bytes.length)
|
||||
});
|
||||
if (!allowedUnhashedSubpackets.has(type)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mypos++;
|
||||
|
||||
// subpacket type
|
||||
switch (type) {
|
||||
case enums.signatureSubpacket.signatureCreationTime:
|
||||
|
Loading…
x
Reference in New Issue
Block a user