mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2025-06-07 14:46:42 +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 hashAlgorithm: enums.hash | null;
|
||||||
public publicKeyAlgorithm: enums.publicKey | null;
|
public publicKeyAlgorithm: enums.publicKey | null;
|
||||||
public signatureData: null | Uint8Array;
|
public signatureData: null | Uint8Array;
|
||||||
public unhashedSubpackets: null | Uint8Array;
|
public unhashedSubpackets: RawSubpacket[];
|
||||||
|
public unknownSubpackets: RawSubpacket[];
|
||||||
public signedHashValue: null | Uint8Array;
|
public signedHashValue: null | Uint8Array;
|
||||||
public created: Date | null;
|
public created: Date | null;
|
||||||
public signatureExpirationTime: null | number;
|
public signatureExpirationTime: null | number;
|
||||||
@ -541,6 +542,12 @@ export class SignaturePacket extends BasePacket {
|
|||||||
public getExpirationTime(): Date | typeof Infinity;
|
public getExpirationTime(): Date | typeof Infinity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface RawSubpacket {
|
||||||
|
type: number;
|
||||||
|
critical: boolean;
|
||||||
|
body: Uint8Array;
|
||||||
|
}
|
||||||
|
|
||||||
export interface RawNotation {
|
export interface RawNotation {
|
||||||
name: string;
|
name: string;
|
||||||
value: Uint8Array;
|
value: Uint8Array;
|
||||||
|
@ -396,10 +396,8 @@ class SignaturePacket {
|
|||||||
* @returns {Uint8Array} Subpacket data.
|
* @returns {Uint8Array} Subpacket data.
|
||||||
*/
|
*/
|
||||||
writeUnhashedSubPackets() {
|
writeUnhashedSubPackets() {
|
||||||
const arr = [];
|
const arr = this.unhashedSubpackets.map(({ type, critical, body }) => {
|
||||||
this.unhashedSubpackets.forEach(data => {
|
return writeSubPacket(type, critical, body);
|
||||||
arr.push(writeSimpleLength(data.length));
|
|
||||||
arr.push(data);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = util.concat(arr);
|
const result = util.concat(arr);
|
||||||
@ -408,7 +406,7 @@ class SignaturePacket {
|
|||||||
return util.concat([length, result]);
|
return util.concat([length, result]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// V4 signature sub packets
|
// Signature subpackets
|
||||||
readSubPacket(bytes, hashed = true) {
|
readSubPacket(bytes, hashed = true) {
|
||||||
let mypos = 0;
|
let mypos = 0;
|
||||||
|
|
||||||
@ -416,15 +414,19 @@ class SignaturePacket {
|
|||||||
const critical = !!(bytes[mypos] & 0x80);
|
const critical = !!(bytes[mypos] & 0x80);
|
||||||
const type = bytes[mypos] & 0x7F;
|
const type = bytes[mypos] & 0x7F;
|
||||||
|
|
||||||
|
mypos++;
|
||||||
|
|
||||||
if (!hashed) {
|
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)) {
|
if (!allowedUnhashedSubpackets.has(type)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mypos++;
|
|
||||||
|
|
||||||
// subpacket type
|
// subpacket type
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case enums.signatureSubpacket.signatureCreationTime:
|
case enums.signatureSubpacket.signatureCreationTime:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user