feat: 초기 프로젝트 설정 및 룰.md 파일 추가

This commit is contained in:
2025-07-28 09:53:31 +09:00
commit 09a4d38512
8165 changed files with 1021855 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AttestationApplicationId = exports.AttestationPackageInfo = void 0;
const tslib_1 = require("tslib");
const asn1_schema_1 = require("@peculiar/asn1-schema");
class AttestationPackageInfo {
constructor(params = {}) {
Object.assign(this, params);
}
}
exports.AttestationPackageInfo = AttestationPackageInfo;
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.OctetString })
], AttestationPackageInfo.prototype, "packageName", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer })
], AttestationPackageInfo.prototype, "version", void 0);
class AttestationApplicationId {
constructor(params = {}) {
Object.assign(this, params);
}
}
exports.AttestationApplicationId = AttestationApplicationId;
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: AttestationPackageInfo, repeated: "set" })
], AttestationApplicationId.prototype, "packageInfos", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.OctetString, repeated: "set" })
], AttestationApplicationId.prototype, "signatureDigests", void 0);

View File

@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./key_description"), exports);
tslib_1.__exportStar(require("./nonstandard"), exports);
tslib_1.__exportStar(require("./attestation"), exports);

View File

@@ -0,0 +1,297 @@
"use strict";
var IntegerSet_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.KeyMintKeyDescription = exports.KeyDescription = exports.Version = exports.SecurityLevel = exports.AuthorizationList = exports.IntegerSet = exports.RootOfTrust = exports.VerifiedBootState = exports.id_ce_keyDescription = void 0;
const tslib_1 = require("tslib");
const asn1_schema_1 = require("@peculiar/asn1-schema");
exports.id_ce_keyDescription = "1.3.6.1.4.1.11129.2.1.17";
var VerifiedBootState;
(function (VerifiedBootState) {
VerifiedBootState[VerifiedBootState["verified"] = 0] = "verified";
VerifiedBootState[VerifiedBootState["selfSigned"] = 1] = "selfSigned";
VerifiedBootState[VerifiedBootState["unverified"] = 2] = "unverified";
VerifiedBootState[VerifiedBootState["failed"] = 3] = "failed";
})(VerifiedBootState || (exports.VerifiedBootState = VerifiedBootState = {}));
class RootOfTrust {
constructor(params = {}) {
this.verifiedBootKey = new asn1_schema_1.OctetString();
this.deviceLocked = false;
this.verifiedBootState = VerifiedBootState.verified;
Object.assign(this, params);
}
}
exports.RootOfTrust = RootOfTrust;
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString })
], RootOfTrust.prototype, "verifiedBootKey", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Boolean })
], RootOfTrust.prototype, "deviceLocked", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Enumerated })
], RootOfTrust.prototype, "verifiedBootState", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString, optional: true })
], RootOfTrust.prototype, "verifiedBootHash", void 0);
let IntegerSet = IntegerSet_1 = class IntegerSet extends asn1_schema_1.AsnArray {
constructor(items) {
super(items);
Object.setPrototypeOf(this, IntegerSet_1.prototype);
}
};
exports.IntegerSet = IntegerSet;
exports.IntegerSet = IntegerSet = IntegerSet_1 = tslib_1.__decorate([
(0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Set, itemType: asn1_schema_1.AsnPropTypes.Integer })
], IntegerSet);
class AuthorizationList {
constructor(params = {}) {
Object.assign(this, params);
}
}
exports.AuthorizationList = AuthorizationList;
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 1, type: IntegerSet, optional: true })
], AuthorizationList.prototype, "purpose", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 2, type: asn1_schema_1.AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "algorithm", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 3, type: asn1_schema_1.AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "keySize", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 5, type: IntegerSet, optional: true })
], AuthorizationList.prototype, "digest", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 6, type: IntegerSet, optional: true })
], AuthorizationList.prototype, "padding", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 10, type: asn1_schema_1.AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "ecCurve", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 200, type: asn1_schema_1.AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "rsaPublicExponent", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 203, type: IntegerSet, optional: true })
], AuthorizationList.prototype, "mgfDigest", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 303, type: asn1_schema_1.AsnPropTypes.Null, optional: true })
], AuthorizationList.prototype, "rollbackResistance", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 305, type: asn1_schema_1.AsnPropTypes.Null, optional: true })
], AuthorizationList.prototype, "earlyBootOnly", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 400, type: asn1_schema_1.AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "activeDateTime", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 401, type: asn1_schema_1.AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "originationExpireDateTime", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 402, type: asn1_schema_1.AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "usageExpireDateTime", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 405, type: asn1_schema_1.AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "usageCountLimit", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 503, type: asn1_schema_1.AsnPropTypes.Null, optional: true })
], AuthorizationList.prototype, "noAuthRequired", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 504, type: asn1_schema_1.AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "userAuthType", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 505, type: asn1_schema_1.AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "authTimeout", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 506, type: asn1_schema_1.AsnPropTypes.Null, optional: true })
], AuthorizationList.prototype, "allowWhileOnBody", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 507, type: asn1_schema_1.AsnPropTypes.Null, optional: true })
], AuthorizationList.prototype, "trustedUserPresenceRequired", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 508, type: asn1_schema_1.AsnPropTypes.Null, optional: true })
], AuthorizationList.prototype, "trustedConfirmationRequired", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 509, type: asn1_schema_1.AsnPropTypes.Null, optional: true })
], AuthorizationList.prototype, "unlockedDeviceRequired", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 600, type: asn1_schema_1.AsnPropTypes.Null, optional: true })
], AuthorizationList.prototype, "allApplications", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 601, type: asn1_schema_1.OctetString, optional: true })
], AuthorizationList.prototype, "applicationId", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 701, type: asn1_schema_1.AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "creationDateTime", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 702, type: asn1_schema_1.AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "origin", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 703, type: asn1_schema_1.AsnPropTypes.Null, optional: true })
], AuthorizationList.prototype, "rollbackResistant", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 704, type: RootOfTrust, optional: true })
], AuthorizationList.prototype, "rootOfTrust", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 705, type: asn1_schema_1.AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "osVersion", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 706, type: asn1_schema_1.AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "osPatchLevel", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 709, type: asn1_schema_1.OctetString, optional: true })
], AuthorizationList.prototype, "attestationApplicationId", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 710, type: asn1_schema_1.OctetString, optional: true })
], AuthorizationList.prototype, "attestationIdBrand", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 711, type: asn1_schema_1.OctetString, optional: true })
], AuthorizationList.prototype, "attestationIdDevice", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 712, type: asn1_schema_1.OctetString, optional: true })
], AuthorizationList.prototype, "attestationIdProduct", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 713, type: asn1_schema_1.OctetString, optional: true })
], AuthorizationList.prototype, "attestationIdSerial", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 714, type: asn1_schema_1.OctetString, optional: true })
], AuthorizationList.prototype, "attestationIdImei", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 715, type: asn1_schema_1.OctetString, optional: true })
], AuthorizationList.prototype, "attestationIdMeid", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 716, type: asn1_schema_1.OctetString, optional: true })
], AuthorizationList.prototype, "attestationIdManufacturer", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 717, type: asn1_schema_1.OctetString, optional: true })
], AuthorizationList.prototype, "attestationIdModel", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 718, type: asn1_schema_1.AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "vendorPatchLevel", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 719, type: asn1_schema_1.AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "bootPatchLevel", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 720, type: asn1_schema_1.AsnPropTypes.Null, optional: true })
], AuthorizationList.prototype, "deviceUniqueAttestation", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 723, type: asn1_schema_1.OctetString, optional: true })
], AuthorizationList.prototype, "attestationIdSecondImei", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ context: 724, type: asn1_schema_1.OctetString, optional: true })
], AuthorizationList.prototype, "moduleHash", void 0);
var SecurityLevel;
(function (SecurityLevel) {
SecurityLevel[SecurityLevel["software"] = 0] = "software";
SecurityLevel[SecurityLevel["trustedEnvironment"] = 1] = "trustedEnvironment";
SecurityLevel[SecurityLevel["strongBox"] = 2] = "strongBox";
})(SecurityLevel || (exports.SecurityLevel = SecurityLevel = {}));
var Version;
(function (Version) {
Version[Version["KM2"] = 1] = "KM2";
Version[Version["KM3"] = 2] = "KM3";
Version[Version["KM4"] = 3] = "KM4";
Version[Version["KM4_1"] = 4] = "KM4_1";
Version[Version["keyMint1"] = 100] = "keyMint1";
Version[Version["keyMint2"] = 200] = "keyMint2";
Version[Version["keyMint3"] = 300] = "keyMint3";
Version[Version["keyMint4"] = 400] = "keyMint4";
})(Version || (exports.Version = Version = {}));
class KeyDescription {
constructor(params = {}) {
this.attestationVersion = Version.KM4;
this.attestationSecurityLevel = SecurityLevel.software;
this.keymasterVersion = 0;
this.keymasterSecurityLevel = SecurityLevel.software;
this.attestationChallenge = new asn1_schema_1.OctetString();
this.uniqueId = new asn1_schema_1.OctetString();
this.softwareEnforced = new AuthorizationList();
this.teeEnforced = new AuthorizationList();
Object.assign(this, params);
}
}
exports.KeyDescription = KeyDescription;
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer })
], KeyDescription.prototype, "attestationVersion", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Enumerated })
], KeyDescription.prototype, "attestationSecurityLevel", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer })
], KeyDescription.prototype, "keymasterVersion", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Enumerated })
], KeyDescription.prototype, "keymasterSecurityLevel", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString })
], KeyDescription.prototype, "attestationChallenge", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString })
], KeyDescription.prototype, "uniqueId", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: AuthorizationList })
], KeyDescription.prototype, "softwareEnforced", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: AuthorizationList })
], KeyDescription.prototype, "teeEnforced", void 0);
class KeyMintKeyDescription {
constructor(params = {}) {
this.attestationVersion = Version.keyMint4;
this.attestationSecurityLevel = SecurityLevel.software;
this.keyMintVersion = 0;
this.keyMintSecurityLevel = SecurityLevel.software;
this.attestationChallenge = new asn1_schema_1.OctetString();
this.uniqueId = new asn1_schema_1.OctetString();
this.softwareEnforced = new AuthorizationList();
this.hardwareEnforced = new AuthorizationList();
Object.assign(this, params);
}
toLegacyKeyDescription() {
return new KeyDescription({
attestationVersion: this.attestationVersion,
attestationSecurityLevel: this.attestationSecurityLevel,
keymasterVersion: this.keyMintVersion,
keymasterSecurityLevel: this.keyMintSecurityLevel,
attestationChallenge: this.attestationChallenge,
uniqueId: this.uniqueId,
softwareEnforced: this.softwareEnforced,
teeEnforced: this.hardwareEnforced,
});
}
static fromLegacyKeyDescription(keyDesc) {
return new KeyMintKeyDescription({
attestationVersion: keyDesc.attestationVersion,
attestationSecurityLevel: keyDesc.attestationSecurityLevel,
keyMintVersion: keyDesc.keymasterVersion,
keyMintSecurityLevel: keyDesc.keymasterSecurityLevel,
attestationChallenge: keyDesc.attestationChallenge,
uniqueId: keyDesc.uniqueId,
softwareEnforced: keyDesc.softwareEnforced,
hardwareEnforced: keyDesc.teeEnforced,
});
}
}
exports.KeyMintKeyDescription = KeyMintKeyDescription;
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer })
], KeyMintKeyDescription.prototype, "attestationVersion", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Enumerated })
], KeyMintKeyDescription.prototype, "attestationSecurityLevel", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer })
], KeyMintKeyDescription.prototype, "keyMintVersion", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Enumerated })
], KeyMintKeyDescription.prototype, "keyMintSecurityLevel", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString })
], KeyMintKeyDescription.prototype, "attestationChallenge", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString })
], KeyMintKeyDescription.prototype, "uniqueId", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: AuthorizationList })
], KeyMintKeyDescription.prototype, "softwareEnforced", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: AuthorizationList })
], KeyMintKeyDescription.prototype, "hardwareEnforced", void 0);

View File

@@ -0,0 +1,104 @@
"use strict";
var NonStandardAuthorizationList_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.NonStandardKeyMintKeyDescription = exports.NonStandardKeyDescription = exports.NonStandardAuthorizationList = exports.NonStandardAuthorization = void 0;
const tslib_1 = require("tslib");
const asn1_schema_1 = require("@peculiar/asn1-schema");
const key_description_1 = require("./key_description");
let NonStandardAuthorization = class NonStandardAuthorization extends key_description_1.AuthorizationList {
};
exports.NonStandardAuthorization = NonStandardAuthorization;
exports.NonStandardAuthorization = NonStandardAuthorization = tslib_1.__decorate([
(0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Choice })
], NonStandardAuthorization);
let NonStandardAuthorizationList = NonStandardAuthorizationList_1 = class NonStandardAuthorizationList extends asn1_schema_1.AsnArray {
constructor(items) {
super(items);
Object.setPrototypeOf(this, NonStandardAuthorizationList_1.prototype);
}
findProperty(key) {
const prop = this.find((o) => key in o);
if (prop) {
return prop[key];
}
return undefined;
}
};
exports.NonStandardAuthorizationList = NonStandardAuthorizationList;
exports.NonStandardAuthorizationList = NonStandardAuthorizationList = NonStandardAuthorizationList_1 = tslib_1.__decorate([
(0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: NonStandardAuthorization })
], NonStandardAuthorizationList);
class NonStandardKeyDescription {
get keyMintVersion() {
return this.keymasterVersion;
}
set keyMintVersion(value) {
this.keymasterVersion = value;
}
get keyMintSecurityLevel() {
return this.keymasterSecurityLevel;
}
set keyMintSecurityLevel(value) {
this.keymasterSecurityLevel = value;
}
get hardwareEnforced() {
return this.teeEnforced;
}
set hardwareEnforced(value) {
this.teeEnforced = value;
}
constructor(params = {}) {
this.attestationVersion = key_description_1.Version.KM4;
this.attestationSecurityLevel = key_description_1.SecurityLevel.software;
this.keymasterVersion = 0;
this.keymasterSecurityLevel = key_description_1.SecurityLevel.software;
this.attestationChallenge = new asn1_schema_1.OctetString();
this.uniqueId = new asn1_schema_1.OctetString();
this.softwareEnforced = new NonStandardAuthorizationList();
this.teeEnforced = new NonStandardAuthorizationList();
Object.assign(this, params);
}
}
exports.NonStandardKeyDescription = NonStandardKeyDescription;
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer })
], NonStandardKeyDescription.prototype, "attestationVersion", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Enumerated })
], NonStandardKeyDescription.prototype, "attestationSecurityLevel", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer })
], NonStandardKeyDescription.prototype, "keymasterVersion", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Enumerated })
], NonStandardKeyDescription.prototype, "keymasterSecurityLevel", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString })
], NonStandardKeyDescription.prototype, "attestationChallenge", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString })
], NonStandardKeyDescription.prototype, "uniqueId", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: NonStandardAuthorizationList })
], NonStandardKeyDescription.prototype, "softwareEnforced", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: NonStandardAuthorizationList })
], NonStandardKeyDescription.prototype, "teeEnforced", void 0);
let NonStandardKeyMintKeyDescription = class NonStandardKeyMintKeyDescription extends NonStandardKeyDescription {
constructor(params = {}) {
if ("keymasterVersion" in params && !("keyMintVersion" in params)) {
params.keyMintVersion = params.keymasterVersion;
}
if ("keymasterSecurityLevel" in params && !("keyMintSecurityLevel" in params)) {
params.keyMintSecurityLevel = params.keymasterSecurityLevel;
}
if ("teeEnforced" in params && !("hardwareEnforced" in params)) {
params.hardwareEnforced = params.teeEnforced;
}
super(params);
}
};
exports.NonStandardKeyMintKeyDescription = NonStandardKeyMintKeyDescription;
exports.NonStandardKeyMintKeyDescription = NonStandardKeyMintKeyDescription = tslib_1.__decorate([
(0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence })
], NonStandardKeyMintKeyDescription);

View File

@@ -0,0 +1,24 @@
import { __decorate } from "tslib";
import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema";
export class AttestationPackageInfo {
constructor(params = {}) {
Object.assign(this, params);
}
}
__decorate([
AsnProp({ type: AsnPropTypes.OctetString })
], AttestationPackageInfo.prototype, "packageName", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Integer })
], AttestationPackageInfo.prototype, "version", void 0);
export class AttestationApplicationId {
constructor(params = {}) {
Object.assign(this, params);
}
}
__decorate([
AsnProp({ type: AttestationPackageInfo, repeated: "set" })
], AttestationApplicationId.prototype, "packageInfos", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.OctetString, repeated: "set" })
], AttestationApplicationId.prototype, "signatureDigests", void 0);

View File

@@ -0,0 +1,3 @@
export * from "./key_description";
export * from "./nonstandard";
export * from "./attestation";

View File

@@ -0,0 +1,290 @@
var IntegerSet_1;
import { __decorate } from "tslib";
import { AsnProp, AsnPropTypes, AsnArray, AsnType, AsnTypeTypes, OctetString, } from "@peculiar/asn1-schema";
export const id_ce_keyDescription = "1.3.6.1.4.1.11129.2.1.17";
export var VerifiedBootState;
(function (VerifiedBootState) {
VerifiedBootState[VerifiedBootState["verified"] = 0] = "verified";
VerifiedBootState[VerifiedBootState["selfSigned"] = 1] = "selfSigned";
VerifiedBootState[VerifiedBootState["unverified"] = 2] = "unverified";
VerifiedBootState[VerifiedBootState["failed"] = 3] = "failed";
})(VerifiedBootState || (VerifiedBootState = {}));
export class RootOfTrust {
constructor(params = {}) {
this.verifiedBootKey = new OctetString();
this.deviceLocked = false;
this.verifiedBootState = VerifiedBootState.verified;
Object.assign(this, params);
}
}
__decorate([
AsnProp({ type: OctetString })
], RootOfTrust.prototype, "verifiedBootKey", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Boolean })
], RootOfTrust.prototype, "deviceLocked", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Enumerated })
], RootOfTrust.prototype, "verifiedBootState", void 0);
__decorate([
AsnProp({ type: OctetString, optional: true })
], RootOfTrust.prototype, "verifiedBootHash", void 0);
let IntegerSet = IntegerSet_1 = class IntegerSet extends AsnArray {
constructor(items) {
super(items);
Object.setPrototypeOf(this, IntegerSet_1.prototype);
}
};
IntegerSet = IntegerSet_1 = __decorate([
AsnType({ type: AsnTypeTypes.Set, itemType: AsnPropTypes.Integer })
], IntegerSet);
export { IntegerSet };
export class AuthorizationList {
constructor(params = {}) {
Object.assign(this, params);
}
}
__decorate([
AsnProp({ context: 1, type: IntegerSet, optional: true })
], AuthorizationList.prototype, "purpose", void 0);
__decorate([
AsnProp({ context: 2, type: AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "algorithm", void 0);
__decorate([
AsnProp({ context: 3, type: AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "keySize", void 0);
__decorate([
AsnProp({ context: 5, type: IntegerSet, optional: true })
], AuthorizationList.prototype, "digest", void 0);
__decorate([
AsnProp({ context: 6, type: IntegerSet, optional: true })
], AuthorizationList.prototype, "padding", void 0);
__decorate([
AsnProp({ context: 10, type: AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "ecCurve", void 0);
__decorate([
AsnProp({ context: 200, type: AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "rsaPublicExponent", void 0);
__decorate([
AsnProp({ context: 203, type: IntegerSet, optional: true })
], AuthorizationList.prototype, "mgfDigest", void 0);
__decorate([
AsnProp({ context: 303, type: AsnPropTypes.Null, optional: true })
], AuthorizationList.prototype, "rollbackResistance", void 0);
__decorate([
AsnProp({ context: 305, type: AsnPropTypes.Null, optional: true })
], AuthorizationList.prototype, "earlyBootOnly", void 0);
__decorate([
AsnProp({ context: 400, type: AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "activeDateTime", void 0);
__decorate([
AsnProp({ context: 401, type: AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "originationExpireDateTime", void 0);
__decorate([
AsnProp({ context: 402, type: AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "usageExpireDateTime", void 0);
__decorate([
AsnProp({ context: 405, type: AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "usageCountLimit", void 0);
__decorate([
AsnProp({ context: 503, type: AsnPropTypes.Null, optional: true })
], AuthorizationList.prototype, "noAuthRequired", void 0);
__decorate([
AsnProp({ context: 504, type: AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "userAuthType", void 0);
__decorate([
AsnProp({ context: 505, type: AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "authTimeout", void 0);
__decorate([
AsnProp({ context: 506, type: AsnPropTypes.Null, optional: true })
], AuthorizationList.prototype, "allowWhileOnBody", void 0);
__decorate([
AsnProp({ context: 507, type: AsnPropTypes.Null, optional: true })
], AuthorizationList.prototype, "trustedUserPresenceRequired", void 0);
__decorate([
AsnProp({ context: 508, type: AsnPropTypes.Null, optional: true })
], AuthorizationList.prototype, "trustedConfirmationRequired", void 0);
__decorate([
AsnProp({ context: 509, type: AsnPropTypes.Null, optional: true })
], AuthorizationList.prototype, "unlockedDeviceRequired", void 0);
__decorate([
AsnProp({ context: 600, type: AsnPropTypes.Null, optional: true })
], AuthorizationList.prototype, "allApplications", void 0);
__decorate([
AsnProp({ context: 601, type: OctetString, optional: true })
], AuthorizationList.prototype, "applicationId", void 0);
__decorate([
AsnProp({ context: 701, type: AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "creationDateTime", void 0);
__decorate([
AsnProp({ context: 702, type: AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "origin", void 0);
__decorate([
AsnProp({ context: 703, type: AsnPropTypes.Null, optional: true })
], AuthorizationList.prototype, "rollbackResistant", void 0);
__decorate([
AsnProp({ context: 704, type: RootOfTrust, optional: true })
], AuthorizationList.prototype, "rootOfTrust", void 0);
__decorate([
AsnProp({ context: 705, type: AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "osVersion", void 0);
__decorate([
AsnProp({ context: 706, type: AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "osPatchLevel", void 0);
__decorate([
AsnProp({ context: 709, type: OctetString, optional: true })
], AuthorizationList.prototype, "attestationApplicationId", void 0);
__decorate([
AsnProp({ context: 710, type: OctetString, optional: true })
], AuthorizationList.prototype, "attestationIdBrand", void 0);
__decorate([
AsnProp({ context: 711, type: OctetString, optional: true })
], AuthorizationList.prototype, "attestationIdDevice", void 0);
__decorate([
AsnProp({ context: 712, type: OctetString, optional: true })
], AuthorizationList.prototype, "attestationIdProduct", void 0);
__decorate([
AsnProp({ context: 713, type: OctetString, optional: true })
], AuthorizationList.prototype, "attestationIdSerial", void 0);
__decorate([
AsnProp({ context: 714, type: OctetString, optional: true })
], AuthorizationList.prototype, "attestationIdImei", void 0);
__decorate([
AsnProp({ context: 715, type: OctetString, optional: true })
], AuthorizationList.prototype, "attestationIdMeid", void 0);
__decorate([
AsnProp({ context: 716, type: OctetString, optional: true })
], AuthorizationList.prototype, "attestationIdManufacturer", void 0);
__decorate([
AsnProp({ context: 717, type: OctetString, optional: true })
], AuthorizationList.prototype, "attestationIdModel", void 0);
__decorate([
AsnProp({ context: 718, type: AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "vendorPatchLevel", void 0);
__decorate([
AsnProp({ context: 719, type: AsnPropTypes.Integer, optional: true })
], AuthorizationList.prototype, "bootPatchLevel", void 0);
__decorate([
AsnProp({ context: 720, type: AsnPropTypes.Null, optional: true })
], AuthorizationList.prototype, "deviceUniqueAttestation", void 0);
__decorate([
AsnProp({ context: 723, type: OctetString, optional: true })
], AuthorizationList.prototype, "attestationIdSecondImei", void 0);
__decorate([
AsnProp({ context: 724, type: OctetString, optional: true })
], AuthorizationList.prototype, "moduleHash", void 0);
export var SecurityLevel;
(function (SecurityLevel) {
SecurityLevel[SecurityLevel["software"] = 0] = "software";
SecurityLevel[SecurityLevel["trustedEnvironment"] = 1] = "trustedEnvironment";
SecurityLevel[SecurityLevel["strongBox"] = 2] = "strongBox";
})(SecurityLevel || (SecurityLevel = {}));
export var Version;
(function (Version) {
Version[Version["KM2"] = 1] = "KM2";
Version[Version["KM3"] = 2] = "KM3";
Version[Version["KM4"] = 3] = "KM4";
Version[Version["KM4_1"] = 4] = "KM4_1";
Version[Version["keyMint1"] = 100] = "keyMint1";
Version[Version["keyMint2"] = 200] = "keyMint2";
Version[Version["keyMint3"] = 300] = "keyMint3";
Version[Version["keyMint4"] = 400] = "keyMint4";
})(Version || (Version = {}));
export class KeyDescription {
constructor(params = {}) {
this.attestationVersion = Version.KM4;
this.attestationSecurityLevel = SecurityLevel.software;
this.keymasterVersion = 0;
this.keymasterSecurityLevel = SecurityLevel.software;
this.attestationChallenge = new OctetString();
this.uniqueId = new OctetString();
this.softwareEnforced = new AuthorizationList();
this.teeEnforced = new AuthorizationList();
Object.assign(this, params);
}
}
__decorate([
AsnProp({ type: AsnPropTypes.Integer })
], KeyDescription.prototype, "attestationVersion", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Enumerated })
], KeyDescription.prototype, "attestationSecurityLevel", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Integer })
], KeyDescription.prototype, "keymasterVersion", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Enumerated })
], KeyDescription.prototype, "keymasterSecurityLevel", void 0);
__decorate([
AsnProp({ type: OctetString })
], KeyDescription.prototype, "attestationChallenge", void 0);
__decorate([
AsnProp({ type: OctetString })
], KeyDescription.prototype, "uniqueId", void 0);
__decorate([
AsnProp({ type: AuthorizationList })
], KeyDescription.prototype, "softwareEnforced", void 0);
__decorate([
AsnProp({ type: AuthorizationList })
], KeyDescription.prototype, "teeEnforced", void 0);
export class KeyMintKeyDescription {
constructor(params = {}) {
this.attestationVersion = Version.keyMint4;
this.attestationSecurityLevel = SecurityLevel.software;
this.keyMintVersion = 0;
this.keyMintSecurityLevel = SecurityLevel.software;
this.attestationChallenge = new OctetString();
this.uniqueId = new OctetString();
this.softwareEnforced = new AuthorizationList();
this.hardwareEnforced = new AuthorizationList();
Object.assign(this, params);
}
toLegacyKeyDescription() {
return new KeyDescription({
attestationVersion: this.attestationVersion,
attestationSecurityLevel: this.attestationSecurityLevel,
keymasterVersion: this.keyMintVersion,
keymasterSecurityLevel: this.keyMintSecurityLevel,
attestationChallenge: this.attestationChallenge,
uniqueId: this.uniqueId,
softwareEnforced: this.softwareEnforced,
teeEnforced: this.hardwareEnforced,
});
}
static fromLegacyKeyDescription(keyDesc) {
return new KeyMintKeyDescription({
attestationVersion: keyDesc.attestationVersion,
attestationSecurityLevel: keyDesc.attestationSecurityLevel,
keyMintVersion: keyDesc.keymasterVersion,
keyMintSecurityLevel: keyDesc.keymasterSecurityLevel,
attestationChallenge: keyDesc.attestationChallenge,
uniqueId: keyDesc.uniqueId,
softwareEnforced: keyDesc.softwareEnforced,
hardwareEnforced: keyDesc.teeEnforced,
});
}
}
__decorate([
AsnProp({ type: AsnPropTypes.Integer })
], KeyMintKeyDescription.prototype, "attestationVersion", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Enumerated })
], KeyMintKeyDescription.prototype, "attestationSecurityLevel", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Integer })
], KeyMintKeyDescription.prototype, "keyMintVersion", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Enumerated })
], KeyMintKeyDescription.prototype, "keyMintSecurityLevel", void 0);
__decorate([
AsnProp({ type: OctetString })
], KeyMintKeyDescription.prototype, "attestationChallenge", void 0);
__decorate([
AsnProp({ type: OctetString })
], KeyMintKeyDescription.prototype, "uniqueId", void 0);
__decorate([
AsnProp({ type: AuthorizationList })
], KeyMintKeyDescription.prototype, "softwareEnforced", void 0);
__decorate([
AsnProp({ type: AuthorizationList })
], KeyMintKeyDescription.prototype, "hardwareEnforced", void 0);

View File

@@ -0,0 +1,100 @@
var NonStandardAuthorizationList_1;
import { __decorate } from "tslib";
import { AsnProp, AsnPropTypes, AsnArray, AsnType, AsnTypeTypes, OctetString, } from "@peculiar/asn1-schema";
import { AuthorizationList, SecurityLevel, Version } from "./key_description";
let NonStandardAuthorization = class NonStandardAuthorization extends AuthorizationList {
};
NonStandardAuthorization = __decorate([
AsnType({ type: AsnTypeTypes.Choice })
], NonStandardAuthorization);
export { NonStandardAuthorization };
let NonStandardAuthorizationList = NonStandardAuthorizationList_1 = class NonStandardAuthorizationList extends AsnArray {
constructor(items) {
super(items);
Object.setPrototypeOf(this, NonStandardAuthorizationList_1.prototype);
}
findProperty(key) {
const prop = this.find((o) => key in o);
if (prop) {
return prop[key];
}
return undefined;
}
};
NonStandardAuthorizationList = NonStandardAuthorizationList_1 = __decorate([
AsnType({ type: AsnTypeTypes.Sequence, itemType: NonStandardAuthorization })
], NonStandardAuthorizationList);
export { NonStandardAuthorizationList };
export class NonStandardKeyDescription {
get keyMintVersion() {
return this.keymasterVersion;
}
set keyMintVersion(value) {
this.keymasterVersion = value;
}
get keyMintSecurityLevel() {
return this.keymasterSecurityLevel;
}
set keyMintSecurityLevel(value) {
this.keymasterSecurityLevel = value;
}
get hardwareEnforced() {
return this.teeEnforced;
}
set hardwareEnforced(value) {
this.teeEnforced = value;
}
constructor(params = {}) {
this.attestationVersion = Version.KM4;
this.attestationSecurityLevel = SecurityLevel.software;
this.keymasterVersion = 0;
this.keymasterSecurityLevel = SecurityLevel.software;
this.attestationChallenge = new OctetString();
this.uniqueId = new OctetString();
this.softwareEnforced = new NonStandardAuthorizationList();
this.teeEnforced = new NonStandardAuthorizationList();
Object.assign(this, params);
}
}
__decorate([
AsnProp({ type: AsnPropTypes.Integer })
], NonStandardKeyDescription.prototype, "attestationVersion", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Enumerated })
], NonStandardKeyDescription.prototype, "attestationSecurityLevel", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Integer })
], NonStandardKeyDescription.prototype, "keymasterVersion", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Enumerated })
], NonStandardKeyDescription.prototype, "keymasterSecurityLevel", void 0);
__decorate([
AsnProp({ type: OctetString })
], NonStandardKeyDescription.prototype, "attestationChallenge", void 0);
__decorate([
AsnProp({ type: OctetString })
], NonStandardKeyDescription.prototype, "uniqueId", void 0);
__decorate([
AsnProp({ type: NonStandardAuthorizationList })
], NonStandardKeyDescription.prototype, "softwareEnforced", void 0);
__decorate([
AsnProp({ type: NonStandardAuthorizationList })
], NonStandardKeyDescription.prototype, "teeEnforced", void 0);
let NonStandardKeyMintKeyDescription = class NonStandardKeyMintKeyDescription extends NonStandardKeyDescription {
constructor(params = {}) {
if ("keymasterVersion" in params && !("keyMintVersion" in params)) {
params.keyMintVersion = params.keymasterVersion;
}
if ("keymasterSecurityLevel" in params && !("keyMintSecurityLevel" in params)) {
params.keyMintSecurityLevel = params.keymasterSecurityLevel;
}
if ("teeEnforced" in params && !("hardwareEnforced" in params)) {
params.hardwareEnforced = params.teeEnforced;
}
super(params);
}
};
NonStandardKeyMintKeyDescription = __decorate([
AsnType({ type: AsnTypeTypes.Sequence })
], NonStandardKeyMintKeyDescription);
export { NonStandardKeyMintKeyDescription };

View File

@@ -0,0 +1,31 @@
import { OctetString } from "@peculiar/asn1-schema";
/**
* Implements ASN.1 structure for attestation package info.
*
* ```asn
* AttestationPackageInfo ::= SEQUENCE {
* package_name OCTET_STRING,
* version INTEGER,
* }
* ```
*/
export declare class AttestationPackageInfo {
packageName: OctetString;
version: number;
constructor(params?: Partial<AttestationPackageInfo>);
}
/**
* Implements ASN.1 structure for attestation application id.
*
* ```asn
* AttestationApplicationId ::= SEQUENCE {
* package_infos SET OF AttestationPackageInfo,
* signature_digests SET OF OCTET_STRING,
* }
* ```
*/
export declare class AttestationApplicationId {
packageInfos: AttestationPackageInfo[];
signatureDigests: OctetString[];
constructor(params?: Partial<AttestationApplicationId>);
}

View File

@@ -0,0 +1,3 @@
export * from "./key_description";
export * from "./nonstandard";
export * from "./attestation";

View File

@@ -0,0 +1,244 @@
import { AsnArray, OctetString } from "@peculiar/asn1-schema";
/**
* Extension OID for key description.
*
* ```asn
* id-ce-keyDescription OBJECT IDENTIFIER ::= { 1 3 6 1 4 1 11129 2 1 17 }
* ```
*/
export declare const id_ce_keyDescription = "1.3.6.1.4.1.11129.2.1.17";
/**
* Implements ASN.1 enumeration for verified boot state.
*
* ```asn
* VerifiedBootState ::= ENUMERATED {
* Verified (0),
* SelfSigned (1),
* Unverified (2),
* Failed (3),
* }
* ```
*/
export declare enum VerifiedBootState {
verified = 0,
selfSigned = 1,
unverified = 2,
failed = 3
}
/**
* Implements ASN.1 structure for root of trust.
*
* ```asn
* RootOfTrust ::= SEQUENCE {
* verifiedBootKey OCTET_STRING,
* deviceLocked BOOLEAN,
* verifiedBootState VerifiedBootState,
* verifiedBootHash OCTET_STRING, # KM4
* }
* ```
*/
export declare class RootOfTrust {
verifiedBootKey: OctetString;
deviceLocked: boolean;
verifiedBootState: VerifiedBootState;
/**
* `verifiedBootHash` must present in `KeyDescription` version 3
*/
verifiedBootHash?: OctetString;
constructor(params?: Partial<RootOfTrust>);
}
/**
* Implements ASN.1 structure for set of integers.
*
* ```asn
* IntegerSet ::= SET OF INTEGER
* ```
*/
export declare class IntegerSet extends AsnArray<number> {
constructor(items?: number[]);
}
/**
* Implements ASN.1 structure for authorization list.
*
* ```asn
* AuthorizationList ::= SEQUENCE {
* purpose [1] EXPLICIT SET OF INTEGER OPTIONAL,
* algorithm [2] EXPLICIT INTEGER OPTIONAL,
* keySize [3] EXPLICIT INTEGER OPTIONAL.
* digest [5] EXPLICIT SET OF INTEGER OPTIONAL,
* padding [6] EXPLICIT SET OF INTEGER OPTIONAL,
* ecCurve [10] EXPLICIT INTEGER OPTIONAL,
* rsaPublicExponent [200] EXPLICIT INTEGER OPTIONAL,
* mgfDigest [203] EXPLICIT SET OF INTEGER OPTIONAL,
* rollbackResistance [303] EXPLICIT NULL OPTIONAL, # KM4
* earlyBootOnly [305] EXPLICIT NULL OPTIONAL, # version 4
* activeDateTime [400] EXPLICIT INTEGER OPTIONAL
* originationExpireDateTime [401] EXPLICIT INTEGER OPTIONAL
* usageExpireDateTime [402] EXPLICIT INTEGER OPTIONAL
* usageCountLimit [405] EXPLICIT INTEGER OPTIONAL,
* noAuthRequired [503] EXPLICIT NULL OPTIONAL,
* userAuthType [504] EXPLICIT INTEGER OPTIONAL,
* authTimeout [505] EXPLICIT INTEGER OPTIONAL,
* allowWhileOnBody [506] EXPLICIT NULL OPTIONAL,
* trustedUserPresenceRequired [507] EXPLICIT NULL OPTIONAL, # KM4
* trustedConfirmationRequired [508] EXPLICIT NULL OPTIONAL, # KM4
* unlockedDeviceRequired [509] EXPLICIT NULL OPTIONAL, # KM4
* allApplications [600] EXPLICIT NULL OPTIONAL,
* applicationId [601] EXPLICIT OCTET_STRING OPTIONAL,
* creationDateTime [701] EXPLICIT INTEGER OPTIONAL,
* origin [702] EXPLICIT INTEGER OPTIONAL,
* rollbackResistant [703] EXPLICIT NULL OPTIONAL, # KM2 and KM3 only.
* rootOfTrust [704] EXPLICIT RootOfTrust OPTIONAL,
* osVersion [705] EXPLICIT INTEGER OPTIONAL,
* osPatchLevel [706] EXPLICIT INTEGER OPTIONAL,
* attestationApplicationId [709] EXPLICIT OCTET_STRING OPTIONAL, # KM3
* attestationIdBrand [710] EXPLICIT OCTET_STRING OPTIONAL, # KM3
* attestationIdDevice [711] EXPLICIT OCTET_STRING OPTIONAL, # KM3
* attestationIdProduct [712] EXPLICIT OCTET_STRING OPTIONAL, # KM3
* attestationIdSerial [713] EXPLICIT OCTET_STRING OPTIONAL, # KM3
* attestationIdImei [714] EXPLICIT OCTET_STRING OPTIONAL, # KM3
* attestationIdMeid [715] EXPLICIT OCTET_STRING OPTIONAL, # KM3
* attestationIdManufacturer [716] EXPLICIT OCTET_STRING OPTIONAL, # KM3
* attestationIdModel [717] EXPLICIT OCTET_STRING OPTIONAL, # KM3
* vendorPatchLevel [718] EXPLICIT INTEGER OPTIONAL, # KM4
* bootPatchLevel [719] EXPLICIT INTEGER OPTIONAL, # KM4
* deviceUniqueAttestation [720] EXPLICIT NULL OPTIONAL, # version 4
* attestationIdSecondImei [723] EXPLICIT OCTET_STRING OPTIONAL,
* moduleHash [724] EXPLICIT OCTET_STRING OPTIONAL,
* }
* ```
*/
export declare class AuthorizationList {
purpose?: IntegerSet;
algorithm?: number;
keySize?: number;
digest?: IntegerSet;
padding?: IntegerSet;
ecCurve?: number;
rsaPublicExponent?: number;
mgfDigest?: IntegerSet;
rollbackResistance?: null;
earlyBootOnly?: null;
activeDateTime?: number;
originationExpireDateTime?: number;
usageExpireDateTime?: number;
usageCountLimit?: number;
noAuthRequired?: null;
userAuthType?: number;
authTimeout?: number;
allowWhileOnBody?: null;
trustedUserPresenceRequired?: null;
trustedConfirmationRequired?: null;
unlockedDeviceRequired?: null;
allApplications?: null;
applicationId?: OctetString;
creationDateTime?: number;
origin?: number;
rollbackResistant?: null;
rootOfTrust?: RootOfTrust;
osVersion?: number;
osPatchLevel?: number;
attestationApplicationId?: OctetString;
attestationIdBrand?: OctetString;
attestationIdDevice?: OctetString;
attestationIdProduct?: OctetString;
attestationIdSerial?: OctetString;
attestationIdImei?: OctetString;
attestationIdMeid?: OctetString;
attestationIdManufacturer?: OctetString;
attestationIdModel?: OctetString;
vendorPatchLevel?: number;
bootPatchLevel?: number;
deviceUniqueAttestation?: null;
attestationIdSecondImei?: OctetString;
moduleHash?: OctetString;
constructor(params?: Partial<AuthorizationList>);
}
/**
* Implements ASN.1 structure for security level.
*
* ```asn
* SecurityLevel ::= ENUMERATED {
* Software (0),
* TrustedEnvironment (1),
* StrongBox (2),
* }
* ```
*/
export declare enum SecurityLevel {
software = 0,
trustedEnvironment = 1,
strongBox = 2
}
export declare enum Version {
KM2 = 1,
KM3 = 2,
KM4 = 3,
KM4_1 = 4,
keyMint1 = 100,
keyMint2 = 200,
keyMint3 = 300,
keyMint4 = 400
}
/**
* Implements ASN.1 structure for key description.
*
* ```asn
* KeyDescription ::= SEQUENCE {
* attestationVersion INTEGER, # versions 1, 2, 3, 4, 100, and 200
* attestationSecurityLevel SecurityLevel,
* keymasterVersion INTEGER,
* keymasterSecurityLevel SecurityLevel,
* attestationChallenge OCTET_STRING,
* uniqueId OCTET_STRING,
* softwareEnforced AuthorizationList,
* teeEnforced AuthorizationList,
* }
* ```
*/
export declare class KeyDescription {
attestationVersion: number | Version;
attestationSecurityLevel: SecurityLevel;
keymasterVersion: number;
keymasterSecurityLevel: SecurityLevel;
attestationChallenge: OctetString;
uniqueId: OctetString;
softwareEnforced: AuthorizationList;
teeEnforced: AuthorizationList;
constructor(params?: Partial<KeyDescription>);
}
/**
* Implements ASN.1 structure for KeyMint key description (v300 and v400).
*
* ```asn
* KeyDescription ::= SEQUENCE {
* attestationVersion INTEGER, # versions 300 and 400
* attestationSecurityLevel SecurityLevel,
* keyMintVersion INTEGER,
* keyMintSecurityLevel SecurityLevel,
* attestationChallenge OCTET_STRING,
* uniqueId OCTET_STRING,
* softwareEnforced AuthorizationList,
* hardwareEnforced AuthorizationList,
* }
* ```
*/
export declare class KeyMintKeyDescription {
attestationVersion: number | Version;
attestationSecurityLevel: SecurityLevel;
keyMintVersion: number;
keyMintSecurityLevel: SecurityLevel;
attestationChallenge: OctetString;
uniqueId: OctetString;
softwareEnforced: AuthorizationList;
hardwareEnforced: AuthorizationList;
constructor(params?: Partial<KeyMintKeyDescription>);
/**
* Convert to legacy KeyDescription for backwards compatibility
*/
toLegacyKeyDescription(): KeyDescription;
/**
* Create from legacy KeyDescription for backwards compatibility
*/
static fromLegacyKeyDescription(keyDesc: KeyDescription): KeyMintKeyDescription;
}

View File

@@ -0,0 +1,83 @@
import { AsnArray, OctetString } from "@peculiar/asn1-schema";
import { AuthorizationList, SecurityLevel, Version } from "./key_description";
/**
* This file contains classes to handle non-standard key descriptions and authorizations.
*
* Due to an issue with the asn1-schema library, referenced at https://github.com/PeculiarVentures/asn1-schema/issues/98#issuecomment-1764345351,
* the standard key description does not allow for a non-strict order of fields in the `softwareEnforced` and `teeEnforced` attributes.
*
* To address this and provide greater flexibility, the `NonStandardKeyDescription` and
* `NonStandardAuthorizationList` classes were created, allowing for the use of non-standard authorizations and a flexible field order.
*
* The purpose of these modifications is to ensure compatibility with specific requirements and standards, as well as to offer
* more convenient tools for working with key descriptions and authorizations.
*
* Please refer to the documentation and class comments before using or modifying them.
*/
/**
* Represents a non-standard authorization for NonStandardAuthorizationList. It uses the same
* structure as AuthorizationList, but it is a CHOICE instead of a SEQUENCE, that allows for
* non-strict ordering of fields.
*/
export declare class NonStandardAuthorization extends AuthorizationList {
}
/**
* Represents a list of non-standard authorizations.
* ```asn
* NonStandardAuthorizationList ::= SEQUENCE OF NonStandardAuthorization
* ```
*/
export declare class NonStandardAuthorizationList extends AsnArray<NonStandardAuthorization> {
constructor(items?: NonStandardAuthorization[]);
/**
* Finds the first authorization that contains the specified key.
* @param key The key to search for.
* @returns The first authorization that contains the specified key, or `undefined` if not found.
*/
findProperty<K extends keyof AuthorizationList>(key: K): AuthorizationList[K] | undefined;
}
/**
* The AuthorizationList class allows for non-strict ordering of fields in the
* softwareEnforced and teeEnforced/hardwareEnforced fields.
*
* This behavior is due to an issue with the asn1-schema library, which is
* documented here: https://github.com/PeculiarVentures/asn1-schema/issues/98#issuecomment-1764345351
*
* ```asn
* KeyDescription ::= SEQUENCE {
* attestationVersion INTEGER, # versions 1, 2, 3, 4, 100, 200, 300, and 400
* attestationSecurityLevel SecurityLevel,
* keymasterVersion/keyMintVersion INTEGER,
* keymasterSecurityLevel/keyMintSecurityLevel SecurityLevel,
* attestationChallenge OCTET_STRING,
* uniqueId OCTET_STRING,
* softwareEnforced NonStandardAuthorizationList,
* teeEnforced/hardwareEnforced NonStandardAuthorizationList,
* }
* ```
*/
export declare class NonStandardKeyDescription {
attestationVersion: number | Version;
attestationSecurityLevel: SecurityLevel;
keymasterVersion: number;
keymasterSecurityLevel: SecurityLevel;
attestationChallenge: OctetString;
uniqueId: OctetString;
softwareEnforced: NonStandardAuthorizationList;
teeEnforced: NonStandardAuthorizationList;
get keyMintVersion(): number;
set keyMintVersion(value: number);
get keyMintSecurityLevel(): SecurityLevel;
set keyMintSecurityLevel(value: SecurityLevel);
get hardwareEnforced(): NonStandardAuthorizationList;
set hardwareEnforced(value: NonStandardAuthorizationList);
constructor(params?: Partial<NonStandardKeyDescription>);
}
/**
* New class for v300 and v400 KeyMint non-standard key description.
* This uses the same underlying structure as NonStandardKeyDescription,
* but with renamed properties to match the updated specification.
*/
export declare class NonStandardKeyMintKeyDescription extends NonStandardKeyDescription {
constructor(params?: Partial<NonStandardKeyDescription>);
}