@simplewebauthn/server 7.4.0 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +11 -14
- package/README.md +20 -7
- package/{dist → esm}/authentication/generateAuthenticationOptions.d.ts +2 -2
- package/esm/authentication/generateAuthenticationOptions.js +36 -0
- package/{dist → esm}/authentication/verifyAuthenticationResponse.d.ts +2 -2
- package/esm/authentication/verifyAuthenticationResponse.js +164 -0
- package/esm/deps.d.ts +11 -0
- package/esm/deps.js +14 -0
- package/esm/helpers/convertAAGUIDToString.js +17 -0
- package/esm/helpers/convertCOSEtoPKCS.js +21 -0
- package/{dist → esm}/helpers/convertCertBufferToPEM.d.ts +1 -1
- package/esm/helpers/convertCertBufferToPEM.js +31 -0
- package/esm/helpers/convertPEMToBytes.js +11 -0
- package/{dist → esm}/helpers/convertX509PublicKeyToCOSE.d.ts +1 -1
- package/esm/helpers/convertX509PublicKeyToCOSE.js +70 -0
- package/{dist → esm}/helpers/cose.d.ts +2 -1
- package/esm/helpers/cose.js +81 -0
- package/{dist → esm}/helpers/decodeAttestationObject.d.ts +3 -0
- package/esm/helpers/decodeAttestationObject.js +13 -0
- package/esm/helpers/decodeAuthenticatorExtensions.js +34 -0
- package/{dist → esm}/helpers/decodeClientDataJSON.d.ts +3 -0
- package/esm/helpers/decodeClientDataJSON.js +13 -0
- package/esm/helpers/decodeCredentialPublicKey.d.ts +5 -0
- package/esm/helpers/decodeCredentialPublicKey.js +8 -0
- package/esm/helpers/fetch.d.ts +8 -0
- package/esm/helpers/fetch.js +12 -0
- package/esm/helpers/generateChallenge.d.ts +7 -0
- package/esm/helpers/generateChallenge.js +21 -0
- package/{dist → esm}/helpers/getCertificateInfo.d.ts +1 -1
- package/esm/helpers/getCertificateInfo.js +76 -0
- package/esm/helpers/index.d.ts +22 -0
- package/esm/helpers/index.js +16 -0
- package/{dist → esm}/helpers/isCertRevoked.d.ts +1 -1
- package/esm/helpers/isCertRevoked.js +98 -0
- package/{dist → esm}/helpers/iso/index.d.ts +4 -4
- package/esm/helpers/iso/index.js +11 -0
- package/esm/helpers/iso/isoBase64URL.js +57 -0
- package/{dist → esm}/helpers/iso/isoCBOR.d.ts +1 -1
- package/esm/helpers/iso/isoCBOR.js +44 -0
- package/{dist → esm}/helpers/iso/isoCrypto/digest.d.ts +1 -1
- package/esm/helpers/iso/isoCrypto/digest.js +14 -0
- package/{dist → esm}/helpers/iso/isoCrypto/getRandomValues.d.ts +1 -1
- package/esm/helpers/iso/isoCrypto/getRandomValues.js +11 -0
- package/esm/helpers/iso/isoCrypto/getWebCrypto.d.ts +6 -0
- package/esm/helpers/iso/isoCrypto/getWebCrypto.js +40 -0
- package/esm/helpers/iso/isoCrypto/importKey.js +8 -0
- package/esm/helpers/iso/isoCrypto/index.d.ts +3 -0
- package/esm/helpers/iso/isoCrypto/index.js +3 -0
- package/{dist → esm}/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.d.ts +2 -2
- package/esm/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.js +20 -0
- package/{dist → esm}/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.d.ts +2 -2
- package/esm/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.js +19 -0
- package/esm/helpers/iso/isoCrypto/structs.js +1 -0
- package/esm/helpers/iso/isoCrypto/unwrapEC2Signature.js +30 -0
- package/{dist → esm}/helpers/iso/isoCrypto/verify.d.ts +1 -1
- package/esm/helpers/iso/isoCrypto/verify.js +28 -0
- package/{dist → esm}/helpers/iso/isoCrypto/verifyEC2.d.ts +1 -1
- package/esm/helpers/iso/isoCrypto/verifyEC2.js +73 -0
- package/{dist → esm}/helpers/iso/isoCrypto/verifyOKP.d.ts +1 -1
- package/esm/helpers/iso/isoCrypto/verifyOKP.js +51 -0
- package/{dist → esm}/helpers/iso/isoCrypto/verifyRSA.d.ts +1 -1
- package/esm/helpers/iso/isoCrypto/verifyRSA.js +91 -0
- package/esm/helpers/iso/isoUint8Array.js +75 -0
- package/{dist → esm}/helpers/logging.d.ts +1 -1
- package/esm/helpers/logging.js +19 -0
- package/{dist → esm}/helpers/mapX509SignatureAlgToCOSEAlg.d.ts +1 -1
- package/esm/helpers/mapX509SignatureAlgToCOSEAlg.js +35 -0
- package/esm/helpers/matchExpectedRPID.js +41 -0
- package/{dist → esm}/helpers/parseAuthenticatorData.d.ts +4 -1
- package/esm/helpers/parseAuthenticatorData.js +71 -0
- package/{dist → esm}/helpers/parseBackupFlags.d.ts +4 -1
- package/esm/helpers/parseBackupFlags.js +25 -0
- package/{dist → esm}/helpers/toHash.d.ts +1 -1
- package/esm/helpers/toHash.js +12 -0
- package/esm/helpers/validateCertificatePath.js +122 -0
- package/{dist → esm}/helpers/verifySignature.d.ts +4 -1
- package/esm/helpers/verifySignature.js +32 -0
- package/esm/index.d.ts +17 -0
- package/esm/index.js +11 -0
- package/{dist → esm}/metadata/mdsTypes.d.ts +1 -1
- package/esm/metadata/mdsTypes.js +17 -0
- package/esm/metadata/parseJWT.js +12 -0
- package/{dist → esm}/metadata/verifyAttestationWithMetadata.d.ts +3 -3
- package/esm/metadata/verifyAttestationWithMetadata.js +159 -0
- package/esm/metadata/verifyJWT.js +37 -0
- package/esm/package.json +3 -0
- package/{dist → esm}/registration/generateRegistrationOptions.d.ts +2 -2
- package/esm/registration/generateRegistrationOptions.js +142 -0
- package/esm/registration/verifications/tpm/constants.js +182 -0
- package/esm/registration/verifications/tpm/parseCertInfo.js +58 -0
- package/esm/registration/verifications/tpm/parsePubArea.js +94 -0
- package/{dist → esm}/registration/verifications/tpm/verifyAttestationTPM.d.ts +1 -1
- package/esm/registration/verifications/tpm/verifyAttestationTPM.js +323 -0
- package/{dist → esm}/registration/verifications/verifyAttestationAndroidKey.d.ts +1 -1
- package/esm/registration/verifications/verifyAttestationAndroidKey.js +90 -0
- package/{dist → esm}/registration/verifications/verifyAttestationAndroidSafetyNet.d.ts +1 -1
- package/esm/registration/verifications/verifyAttestationAndroidSafetyNet.js +112 -0
- package/{dist → esm}/registration/verifications/verifyAttestationApple.d.ts +1 -1
- package/esm/registration/verifications/verifyAttestationApple.js +57 -0
- package/{dist → esm}/registration/verifications/verifyAttestationFIDOU2F.d.ts +1 -1
- package/esm/registration/verifications/verifyAttestationFIDOU2F.js +48 -0
- package/{dist → esm}/registration/verifications/verifyAttestationPacked.d.ts +1 -1
- package/esm/registration/verifications/verifyAttestationPacked.js +105 -0
- package/{dist → esm}/registration/verifyRegistrationResponse.d.ts +3 -3
- package/esm/registration/verifyRegistrationResponse.js +198 -0
- package/esm/services/defaultRootCerts/android-key.js +85 -0
- package/esm/services/defaultRootCerts/android-safetynet.js +32 -0
- package/esm/services/defaultRootCerts/apple.js +25 -0
- package/esm/services/defaultRootCerts/mds.js +32 -0
- package/{dist → esm}/services/metadataService.d.ts +1 -1
- package/{dist → esm}/services/metadataService.js +52 -36
- package/{dist → esm}/services/settingsService.d.ts +1 -1
- package/esm/services/settingsService.js +65 -0
- package/package.json +40 -42
- package/script/authentication/generateAuthenticationOptions.d.ts +23 -0
- package/{dist → script}/authentication/generateAuthenticationOptions.js +8 -9
- package/script/authentication/verifyAuthenticationResponse.d.ts +66 -0
- package/{dist → script}/authentication/verifyAuthenticationResponse.js +25 -23
- package/script/deps.d.ts +11 -0
- package/script/deps.js +71 -0
- package/script/helpers/convertAAGUIDToString.d.ts +4 -0
- package/{dist → script}/helpers/convertAAGUIDToString.js +2 -3
- package/script/helpers/convertCOSEtoPKCS.d.ts +4 -0
- package/{dist → script}/helpers/convertCOSEtoPKCS.js +7 -8
- package/script/helpers/convertCertBufferToPEM.d.ts +5 -0
- package/{dist → script}/helpers/convertCertBufferToPEM.js +5 -6
- package/script/helpers/convertPEMToBytes.d.ts +4 -0
- package/{dist → script}/helpers/convertPEMToBytes.js +2 -3
- package/script/helpers/convertX509PublicKeyToCOSE.d.ts +2 -0
- package/{dist → script}/helpers/convertX509PublicKeyToCOSE.js +21 -25
- package/script/helpers/cose.d.ts +98 -0
- package/{dist → script}/helpers/cose.js +1 -1
- package/script/helpers/decodeAttestationObject.d.ts +29 -0
- package/script/helpers/decodeAttestationObject.js +17 -0
- package/script/helpers/decodeAuthenticatorExtensions.d.ts +20 -0
- package/{dist → script}/helpers/decodeAuthenticatorExtensions.js +2 -3
- package/script/helpers/decodeClientDataJSON.d.ts +17 -0
- package/script/helpers/decodeClientDataJSON.js +17 -0
- package/script/helpers/decodeCredentialPublicKey.d.ts +5 -0
- package/script/helpers/decodeCredentialPublicKey.js +12 -0
- package/script/helpers/fetch.d.ts +8 -0
- package/script/helpers/fetch.js +16 -0
- package/script/helpers/generateChallenge.d.ts +7 -0
- package/{dist → script}/helpers/generateChallenge.js +9 -6
- package/script/helpers/getCertificateInfo.d.ts +31 -0
- package/{dist → script}/helpers/getCertificateInfo.js +4 -6
- package/script/helpers/index.d.ts +22 -0
- package/script/helpers/index.js +59 -0
- package/script/helpers/isCertRevoked.d.ts +8 -0
- package/{dist → script}/helpers/isCertRevoked.js +20 -25
- package/script/helpers/iso/index.d.ts +11 -0
- package/{dist → script}/helpers/iso/index.js +4 -5
- package/script/helpers/iso/isoBase64URL.d.ts +37 -0
- package/{dist → script}/helpers/iso/isoBase64URL.js +9 -13
- package/script/helpers/iso/isoCBOR.d.ts +12 -0
- package/{dist → script}/helpers/iso/isoCBOR.js +8 -28
- package/script/helpers/iso/isoCrypto/digest.d.ts +8 -0
- package/script/helpers/iso/isoCrypto/digest.js +18 -0
- package/script/helpers/iso/isoCrypto/getRandomValues.d.ts +6 -0
- package/script/helpers/iso/isoCrypto/getRandomValues.js +15 -0
- package/script/helpers/iso/isoCrypto/getWebCrypto.d.ts +6 -0
- package/script/helpers/iso/isoCrypto/getWebCrypto.js +44 -0
- package/script/helpers/iso/isoCrypto/importKey.d.ts +4 -0
- package/script/helpers/iso/isoCrypto/importKey.js +12 -0
- package/script/helpers/iso/isoCrypto/index.d.ts +3 -0
- package/{dist → script}/helpers/iso/isoCrypto/index.js +6 -7
- package/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.d.ts +6 -0
- package/{dist → script}/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.js +6 -6
- package/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.d.ts +6 -0
- package/{dist → script}/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.js +5 -6
- package/script/helpers/iso/isoCrypto/structs.d.ts +3 -0
- package/{dist → script}/helpers/iso/isoCrypto/structs.js +0 -1
- package/script/helpers/iso/isoCrypto/unwrapEC2Signature.d.ts +6 -0
- package/{dist → script}/helpers/iso/isoCrypto/unwrapEC2Signature.js +4 -6
- package/script/helpers/iso/isoCrypto/verify.d.ts +10 -0
- package/script/helpers/iso/isoCrypto/verify.js +32 -0
- package/script/helpers/iso/isoCrypto/verifyEC2.d.ts +10 -0
- package/{dist → script}/helpers/iso/isoCrypto/verifyEC2.js +19 -22
- package/script/helpers/iso/isoCrypto/verifyOKP.d.ts +6 -0
- package/{dist → script}/helpers/iso/isoCrypto/verifyOKP.js +13 -16
- package/script/helpers/iso/isoCrypto/verifyRSA.d.ts +10 -0
- package/{dist → script}/helpers/iso/isoCrypto/verifyRSA.js +19 -22
- package/script/helpers/iso/isoUint8Array.d.ts +36 -0
- package/{dist → script}/helpers/iso/isoUint8Array.js +7 -8
- package/script/helpers/logging.d.ts +17 -0
- package/{dist → script}/helpers/logging.js +2 -6
- package/script/helpers/mapX509SignatureAlgToCOSEAlg.d.ts +8 -0
- package/{dist → script}/helpers/mapX509SignatureAlgToCOSEAlg.js +8 -9
- package/script/helpers/matchExpectedRPID.d.ts +7 -0
- package/{dist → script}/helpers/matchExpectedRPID.js +5 -6
- package/script/helpers/parseAuthenticatorData.d.ts +28 -0
- package/{dist → script}/helpers/parseAuthenticatorData.js +19 -16
- package/script/helpers/parseBackupFlags.d.ts +19 -0
- package/{dist → script}/helpers/parseBackupFlags.js +2 -2
- package/script/helpers/toHash.d.ts +6 -0
- package/{dist → script}/helpers/toHash.js +4 -5
- package/script/helpers/validateCertificatePath.d.ts +6 -0
- package/{dist → script}/helpers/validateCertificatePath.js +13 -15
- package/script/helpers/verifySignature.d.ts +14 -0
- package/script/helpers/verifySignature.js +36 -0
- package/script/index.d.ts +17 -0
- package/script/index.js +19 -0
- package/script/metadata/mdsTypes.d.ts +216 -0
- package/{dist → script}/metadata/mdsTypes.js +0 -1
- package/script/metadata/parseJWT.d.ts +4 -0
- package/{dist → script}/metadata/parseJWT.js +3 -4
- package/script/metadata/verifyAttestationWithMetadata.d.ts +29 -0
- package/{dist → script}/metadata/verifyAttestationWithMetadata.js +24 -22
- package/script/metadata/verifyJWT.d.ts +10 -0
- package/script/metadata/verifyJWT.js +41 -0
- package/script/package.json +3 -0
- package/script/registration/generateRegistrationOptions.d.ts +43 -0
- package/{dist → script}/registration/generateRegistrationOptions.js +9 -10
- package/script/registration/verifications/tpm/constants.d.ts +47 -0
- package/{dist → script}/registration/verifications/tpm/constants.js +1 -2
- package/script/registration/verifications/tpm/parseCertInfo.d.ts +24 -0
- package/{dist → script}/registration/verifications/tpm/parseCertInfo.js +13 -14
- package/script/registration/verifications/tpm/parsePubArea.d.ts +43 -0
- package/{dist → script}/registration/verifications/tpm/parsePubArea.js +16 -17
- package/script/registration/verifications/tpm/verifyAttestationTPM.d.ts +2 -0
- package/{dist → script}/registration/verifications/tpm/verifyAttestationTPM.js +58 -58
- package/script/registration/verifications/verifyAttestationAndroidKey.d.ts +5 -0
- package/{dist → script}/registration/verifications/verifyAttestationAndroidKey.js +22 -26
- package/script/registration/verifications/verifyAttestationAndroidSafetyNet.d.ts +5 -0
- package/{dist → script}/registration/verifications/verifyAttestationAndroidSafetyNet.js +22 -23
- package/script/registration/verifications/verifyAttestationApple.d.ts +2 -0
- package/{dist → script}/registration/verifications/verifyAttestationApple.js +15 -17
- package/script/registration/verifications/verifyAttestationFIDOU2F.d.ts +5 -0
- package/{dist → script}/registration/verifications/verifyAttestationFIDOU2F.js +12 -13
- package/script/registration/verifications/verifyAttestationPacked.d.ts +5 -0
- package/{dist → script}/registration/verifications/verifyAttestationPacked.js +17 -18
- package/script/registration/verifyRegistrationResponse.d.ts +85 -0
- package/{dist → script}/registration/verifyRegistrationResponse.js +39 -38
- package/script/services/defaultRootCerts/android-key.d.ts +24 -0
- package/{dist → script}/services/defaultRootCerts/android-key.js +0 -1
- package/script/services/defaultRootCerts/android-safetynet.d.ts +11 -0
- package/{dist → script}/services/defaultRootCerts/android-safetynet.js +0 -1
- package/script/services/defaultRootCerts/apple.d.ts +11 -0
- package/{dist → script}/services/defaultRootCerts/apple.js +0 -1
- package/script/services/defaultRootCerts/mds.d.ts +11 -0
- package/{dist → script}/services/defaultRootCerts/mds.js +0 -1
- package/script/services/metadataService.d.ts +53 -0
- package/script/services/metadataService.js +277 -0
- package/script/services/settingsService.d.ts +25 -0
- package/{dist → script}/services/settingsService.js +21 -13
- package/dist/authentication/generateAuthenticationOptions.js.map +0 -1
- package/dist/authentication/verifyAuthenticationResponse.js.map +0 -1
- package/dist/helpers/convertAAGUIDToString.js.map +0 -1
- package/dist/helpers/convertCOSEtoPKCS.js.map +0 -1
- package/dist/helpers/convertCertBufferToPEM.js.map +0 -1
- package/dist/helpers/convertPEMToBytes.js.map +0 -1
- package/dist/helpers/convertX509PublicKeyToCOSE.js.map +0 -1
- package/dist/helpers/cose.js.map +0 -1
- package/dist/helpers/decodeAttestationObject.js +0 -14
- package/dist/helpers/decodeAttestationObject.js.map +0 -1
- package/dist/helpers/decodeAuthenticatorExtensions.js.map +0 -1
- package/dist/helpers/decodeClientDataJSON.js +0 -14
- package/dist/helpers/decodeClientDataJSON.js.map +0 -1
- package/dist/helpers/decodeCredentialPublicKey.d.ts +0 -2
- package/dist/helpers/decodeCredentialPublicKey.js +0 -9
- package/dist/helpers/decodeCredentialPublicKey.js.map +0 -1
- package/dist/helpers/generateChallenge.d.ts +0 -4
- package/dist/helpers/generateChallenge.js.map +0 -1
- package/dist/helpers/getCertificateInfo.js.map +0 -1
- package/dist/helpers/index.d.ts +0 -22
- package/dist/helpers/index.js +0 -60
- package/dist/helpers/index.js.map +0 -1
- package/dist/helpers/isCertRevoked.js.map +0 -1
- package/dist/helpers/iso/index.js.map +0 -1
- package/dist/helpers/iso/isoBase64URL.js.map +0 -1
- package/dist/helpers/iso/isoCBOR.js.map +0 -1
- package/dist/helpers/iso/isoCrypto/digest.js +0 -21
- package/dist/helpers/iso/isoCrypto/digest.js.map +0 -1
- package/dist/helpers/iso/isoCrypto/getRandomValues.js +0 -18
- package/dist/helpers/iso/isoCrypto/getRandomValues.js.map +0 -1
- package/dist/helpers/iso/isoCrypto/importKey.js +0 -13
- package/dist/helpers/iso/isoCrypto/importKey.js.map +0 -1
- package/dist/helpers/iso/isoCrypto/index.d.ts +0 -3
- package/dist/helpers/iso/isoCrypto/index.js.map +0 -1
- package/dist/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.js.map +0 -1
- package/dist/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.js.map +0 -1
- package/dist/helpers/iso/isoCrypto/structs.js.map +0 -1
- package/dist/helpers/iso/isoCrypto/unwrapEC2Signature.js.map +0 -1
- package/dist/helpers/iso/isoCrypto/verify.js +0 -28
- package/dist/helpers/iso/isoCrypto/verify.js.map +0 -1
- package/dist/helpers/iso/isoCrypto/verifyEC2.js.map +0 -1
- package/dist/helpers/iso/isoCrypto/verifyOKP.js.map +0 -1
- package/dist/helpers/iso/isoCrypto/verifyRSA.js.map +0 -1
- package/dist/helpers/iso/isoUint8Array.js.map +0 -1
- package/dist/helpers/logging.js.map +0 -1
- package/dist/helpers/mapX509SignatureAlgToCOSEAlg.js.map +0 -1
- package/dist/helpers/matchExpectedRPID.js.map +0 -1
- package/dist/helpers/parseAuthenticatorData.js.map +0 -1
- package/dist/helpers/parseBackupFlags.js.map +0 -1
- package/dist/helpers/toHash.js.map +0 -1
- package/dist/helpers/validateCertificatePath.js.map +0 -1
- package/dist/helpers/verifySignature.js +0 -33
- package/dist/helpers/verifySignature.js.map +0 -1
- package/dist/index.d.ts +0 -17
- package/dist/index.js +0 -20
- package/dist/index.js.map +0 -1
- package/dist/metadata/mdsTypes.js.map +0 -1
- package/dist/metadata/parseJWT.js.map +0 -1
- package/dist/metadata/verifyAttestationWithMetadata.js.map +0 -1
- package/dist/metadata/verifyJWT.js +0 -42
- package/dist/metadata/verifyJWT.js.map +0 -1
- package/dist/registration/generateRegistrationOptions.js.map +0 -1
- package/dist/registration/verifications/tpm/constants.js.map +0 -1
- package/dist/registration/verifications/tpm/parseCertInfo.js.map +0 -1
- package/dist/registration/verifications/tpm/parsePubArea.js.map +0 -1
- package/dist/registration/verifications/tpm/verifyAttestationTPM.js.map +0 -1
- package/dist/registration/verifications/verifyAttestationAndroidKey.js.map +0 -1
- package/dist/registration/verifications/verifyAttestationAndroidSafetyNet.js.map +0 -1
- package/dist/registration/verifications/verifyAttestationApple.js.map +0 -1
- package/dist/registration/verifications/verifyAttestationFIDOU2F.js.map +0 -1
- package/dist/registration/verifications/verifyAttestationPacked.js.map +0 -1
- package/dist/registration/verifyRegistrationResponse.js.map +0 -1
- package/dist/services/defaultRootCerts/android-key.js.map +0 -1
- package/dist/services/defaultRootCerts/android-safetynet.js.map +0 -1
- package/dist/services/defaultRootCerts/apple.js.map +0 -1
- package/dist/services/defaultRootCerts/mds.js.map +0 -1
- package/dist/services/metadataService.js.map +0 -1
- package/dist/services/settingsService.js.map +0 -1
- /package/{dist → esm}/helpers/convertAAGUIDToString.d.ts +0 -0
- /package/{dist → esm}/helpers/convertCOSEtoPKCS.d.ts +0 -0
- /package/{dist → esm}/helpers/convertPEMToBytes.d.ts +0 -0
- /package/{dist → esm}/helpers/decodeAuthenticatorExtensions.d.ts +0 -0
- /package/{dist → esm}/helpers/iso/isoBase64URL.d.ts +0 -0
- /package/{dist → esm}/helpers/iso/isoCrypto/importKey.d.ts +0 -0
- /package/{dist → esm}/helpers/iso/isoCrypto/structs.d.ts +0 -0
- /package/{dist → esm}/helpers/iso/isoCrypto/unwrapEC2Signature.d.ts +0 -0
- /package/{dist → esm}/helpers/iso/isoUint8Array.d.ts +0 -0
- /package/{dist → esm}/helpers/matchExpectedRPID.d.ts +0 -0
- /package/{dist → esm}/helpers/validateCertificatePath.d.ts +0 -0
- /package/{dist → esm}/metadata/parseJWT.d.ts +0 -0
- /package/{dist → esm}/metadata/verifyJWT.d.ts +0 -0
- /package/{dist → esm}/registration/verifications/tpm/constants.d.ts +0 -0
- /package/{dist → esm}/registration/verifications/tpm/parseCertInfo.d.ts +0 -0
- /package/{dist → esm}/registration/verifications/tpm/parsePubArea.d.ts +0 -0
- /package/{dist → esm}/services/defaultRootCerts/android-key.d.ts +0 -0
- /package/{dist → esm}/services/defaultRootCerts/android-safetynet.d.ts +0 -0
- /package/{dist → esm}/services/defaultRootCerts/apple.d.ts +0 -0
- /package/{dist → esm}/services/defaultRootCerts/mds.d.ts +0 -0
|
@@ -1,50 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseCertInfo = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const constants_js_1 = require("./constants.js");
|
|
5
|
+
const index_js_1 = require("../../../helpers/iso/index.js");
|
|
6
6
|
/**
|
|
7
7
|
* Cut up a TPM attestation's certInfo into intelligible chunks
|
|
8
8
|
*/
|
|
9
9
|
function parseCertInfo(certInfo) {
|
|
10
10
|
let pointer = 0;
|
|
11
|
-
const dataView =
|
|
11
|
+
const dataView = index_js_1.isoUint8Array.toDataView(certInfo);
|
|
12
12
|
// Get a magic constant
|
|
13
13
|
const magic = dataView.getUint32(pointer);
|
|
14
14
|
pointer += 4;
|
|
15
15
|
// Determine the algorithm used for attestation
|
|
16
16
|
const typeBuffer = dataView.getUint16(pointer);
|
|
17
17
|
pointer += 2;
|
|
18
|
-
const type =
|
|
18
|
+
const type = constants_js_1.TPM_ST[typeBuffer];
|
|
19
19
|
// The name of a parent entity, can be ignored
|
|
20
20
|
const qualifiedSignerLength = dataView.getUint16(pointer);
|
|
21
21
|
pointer += 2;
|
|
22
|
-
const qualifiedSigner = certInfo.slice(pointer,
|
|
22
|
+
const qualifiedSigner = certInfo.slice(pointer, pointer += qualifiedSignerLength);
|
|
23
23
|
// Get the expected hash of `attsToBeSigned`
|
|
24
24
|
const extraDataLength = dataView.getUint16(pointer);
|
|
25
25
|
pointer += 2;
|
|
26
|
-
const extraData = certInfo.slice(pointer,
|
|
26
|
+
const extraData = certInfo.slice(pointer, pointer += extraDataLength);
|
|
27
27
|
// Information about the TPM device's internal clock, can be ignored
|
|
28
|
-
const clock = certInfo.slice(pointer,
|
|
28
|
+
const clock = certInfo.slice(pointer, pointer += 8);
|
|
29
29
|
const resetCount = dataView.getUint32(pointer);
|
|
30
30
|
pointer += 4;
|
|
31
31
|
const restartCount = dataView.getUint32(pointer);
|
|
32
32
|
pointer += 4;
|
|
33
|
-
const safe = !!certInfo.slice(pointer,
|
|
33
|
+
const safe = !!certInfo.slice(pointer, pointer += 1);
|
|
34
34
|
const clockInfo = { clock, resetCount, restartCount, safe };
|
|
35
35
|
// TPM device firmware version
|
|
36
|
-
const firmwareVersion = certInfo.slice(pointer,
|
|
36
|
+
const firmwareVersion = certInfo.slice(pointer, pointer += 8);
|
|
37
37
|
// Attested Name
|
|
38
38
|
const attestedNameLength = dataView.getUint16(pointer);
|
|
39
39
|
pointer += 2;
|
|
40
|
-
const attestedName = certInfo.slice(pointer,
|
|
41
|
-
const attestedNameDataView =
|
|
40
|
+
const attestedName = certInfo.slice(pointer, pointer += attestedNameLength);
|
|
41
|
+
const attestedNameDataView = index_js_1.isoUint8Array.toDataView(attestedName);
|
|
42
42
|
// Attested qualified name, can be ignored
|
|
43
43
|
const qualifiedNameLength = dataView.getUint16(pointer);
|
|
44
44
|
pointer += 2;
|
|
45
|
-
const qualifiedName = certInfo.slice(pointer,
|
|
45
|
+
const qualifiedName = certInfo.slice(pointer, pointer += qualifiedNameLength);
|
|
46
46
|
const attested = {
|
|
47
|
-
nameAlg:
|
|
47
|
+
nameAlg: constants_js_1.TPM_ALG[attestedNameDataView.getUint16(0)],
|
|
48
48
|
nameAlgBuffer: attestedName.slice(0, 2),
|
|
49
49
|
name: attestedName,
|
|
50
50
|
qualifiedName,
|
|
@@ -60,4 +60,3 @@ function parseCertInfo(certInfo) {
|
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
exports.parseCertInfo = parseCertInfo;
|
|
63
|
-
//# sourceMappingURL=parseCertInfo.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Break apart a TPM attestation's pubArea buffer
|
|
3
|
+
*
|
|
4
|
+
* See 12.2.4 TPMT_PUBLIC here:
|
|
5
|
+
* https://trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-2-Structures-00.96-130315.pdf
|
|
6
|
+
*/
|
|
7
|
+
export declare function parsePubArea(pubArea: Uint8Array): ParsedPubArea;
|
|
8
|
+
type ParsedPubArea = {
|
|
9
|
+
type: 'TPM_ALG_RSA' | 'TPM_ALG_ECC';
|
|
10
|
+
nameAlg: string;
|
|
11
|
+
objectAttributes: {
|
|
12
|
+
fixedTPM: boolean;
|
|
13
|
+
stClear: boolean;
|
|
14
|
+
fixedParent: boolean;
|
|
15
|
+
sensitiveDataOrigin: boolean;
|
|
16
|
+
userWithAuth: boolean;
|
|
17
|
+
adminWithPolicy: boolean;
|
|
18
|
+
noDA: boolean;
|
|
19
|
+
encryptedDuplication: boolean;
|
|
20
|
+
restricted: boolean;
|
|
21
|
+
decrypt: boolean;
|
|
22
|
+
signOrEncrypt: boolean;
|
|
23
|
+
};
|
|
24
|
+
authPolicy: Uint8Array;
|
|
25
|
+
parameters: {
|
|
26
|
+
rsa?: RSAParameters;
|
|
27
|
+
ecc?: ECCParameters;
|
|
28
|
+
};
|
|
29
|
+
unique: Uint8Array;
|
|
30
|
+
};
|
|
31
|
+
type RSAParameters = {
|
|
32
|
+
symmetric: string;
|
|
33
|
+
scheme: string;
|
|
34
|
+
keyBits: number;
|
|
35
|
+
exponent: number;
|
|
36
|
+
};
|
|
37
|
+
type ECCParameters = {
|
|
38
|
+
symmetric: string;
|
|
39
|
+
scheme: string;
|
|
40
|
+
curveID: string;
|
|
41
|
+
kdf: string;
|
|
42
|
+
};
|
|
43
|
+
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parsePubArea = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const constants_js_1 = require("./constants.js");
|
|
5
|
+
const index_js_1 = require("../../../helpers/iso/index.js");
|
|
6
6
|
/**
|
|
7
7
|
* Break apart a TPM attestation's pubArea buffer
|
|
8
8
|
*
|
|
@@ -11,10 +11,10 @@ const iso_1 = require("../../../helpers/iso");
|
|
|
11
11
|
*/
|
|
12
12
|
function parsePubArea(pubArea) {
|
|
13
13
|
let pointer = 0;
|
|
14
|
-
const dataView =
|
|
15
|
-
const type =
|
|
14
|
+
const dataView = index_js_1.isoUint8Array.toDataView(pubArea);
|
|
15
|
+
const type = constants_js_1.TPM_ALG[dataView.getUint16(pointer)];
|
|
16
16
|
pointer += 2;
|
|
17
|
-
const nameAlg =
|
|
17
|
+
const nameAlg = constants_js_1.TPM_ALG[dataView.getUint16(pointer)];
|
|
18
18
|
pointer += 2;
|
|
19
19
|
// Get some authenticator attributes(?)
|
|
20
20
|
// const objectAttributesInt = pubArea.slice(pointer, (pointer += 4)).readUInt32BE(0);
|
|
@@ -36,14 +36,14 @@ function parsePubArea(pubArea) {
|
|
|
36
36
|
// Slice out the authPolicy of dynamic length
|
|
37
37
|
const authPolicyLength = dataView.getUint16(pointer);
|
|
38
38
|
pointer += 2;
|
|
39
|
-
const authPolicy = pubArea.slice(pointer,
|
|
39
|
+
const authPolicy = pubArea.slice(pointer, pointer += authPolicyLength);
|
|
40
40
|
// Extract additional curve params according to type
|
|
41
41
|
const parameters = {};
|
|
42
42
|
let unique = Uint8Array.from([]);
|
|
43
43
|
if (type === 'TPM_ALG_RSA') {
|
|
44
|
-
const symmetric =
|
|
44
|
+
const symmetric = constants_js_1.TPM_ALG[dataView.getUint16(pointer)];
|
|
45
45
|
pointer += 2;
|
|
46
|
-
const scheme =
|
|
46
|
+
const scheme = constants_js_1.TPM_ALG[dataView.getUint16(pointer)];
|
|
47
47
|
pointer += 2;
|
|
48
48
|
const keyBits = dataView.getUint16(pointer);
|
|
49
49
|
pointer += 2;
|
|
@@ -57,16 +57,16 @@ function parsePubArea(pubArea) {
|
|
|
57
57
|
// const uniqueLength = pubArea.slice(pointer, (pointer += 2)).readUInt16BE(0);
|
|
58
58
|
const uniqueLength = dataView.getUint16(pointer);
|
|
59
59
|
pointer += 2;
|
|
60
|
-
unique = pubArea.slice(pointer,
|
|
60
|
+
unique = pubArea.slice(pointer, pointer += uniqueLength);
|
|
61
61
|
}
|
|
62
62
|
else if (type === 'TPM_ALG_ECC') {
|
|
63
|
-
const symmetric =
|
|
63
|
+
const symmetric = constants_js_1.TPM_ALG[dataView.getUint16(pointer)];
|
|
64
64
|
pointer += 2;
|
|
65
|
-
const scheme =
|
|
65
|
+
const scheme = constants_js_1.TPM_ALG[dataView.getUint16(pointer)];
|
|
66
66
|
pointer += 2;
|
|
67
|
-
const curveID =
|
|
67
|
+
const curveID = constants_js_1.TPM_ECC_CURVE[dataView.getUint16(pointer)];
|
|
68
68
|
pointer += 2;
|
|
69
|
-
const kdf =
|
|
69
|
+
const kdf = constants_js_1.TPM_ALG[dataView.getUint16(pointer)];
|
|
70
70
|
pointer += 2;
|
|
71
71
|
parameters.ecc = { symmetric, scheme, curveID, kdf };
|
|
72
72
|
/**
|
|
@@ -76,12 +76,12 @@ function parsePubArea(pubArea) {
|
|
|
76
76
|
// Retrieve X
|
|
77
77
|
const uniqueXLength = dataView.getUint16(pointer);
|
|
78
78
|
pointer += 2;
|
|
79
|
-
const uniqueX = pubArea.slice(pointer,
|
|
79
|
+
const uniqueX = pubArea.slice(pointer, pointer += uniqueXLength);
|
|
80
80
|
// Retrieve Y
|
|
81
81
|
const uniqueYLength = dataView.getUint16(pointer);
|
|
82
82
|
pointer += 2;
|
|
83
|
-
const uniqueY = pubArea.slice(pointer,
|
|
84
|
-
unique =
|
|
83
|
+
const uniqueY = pubArea.slice(pointer, pointer += uniqueYLength);
|
|
84
|
+
unique = index_js_1.isoUint8Array.concat([uniqueX, uniqueY]);
|
|
85
85
|
}
|
|
86
86
|
else {
|
|
87
87
|
throw new Error(`Unexpected type "${type}" (TPM)`);
|
|
@@ -96,4 +96,3 @@ function parsePubArea(pubArea) {
|
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
98
|
exports.parsePubArea = parsePubArea;
|
|
99
|
-
//# sourceMappingURL=parsePubArea.js.map
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.verifyAttestationTPM = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const parsePubArea_1 = require("./parsePubArea");
|
|
4
|
+
const deps_js_1 = require("../../../deps.js");
|
|
5
|
+
const decodeCredentialPublicKey_js_1 = require("../../../helpers/decodeCredentialPublicKey.js");
|
|
6
|
+
const cose_js_1 = require("../../../helpers/cose.js");
|
|
7
|
+
const toHash_js_1 = require("../../../helpers/toHash.js");
|
|
8
|
+
const convertCertBufferToPEM_js_1 = require("../../../helpers/convertCertBufferToPEM.js");
|
|
9
|
+
const validateCertificatePath_js_1 = require("../../../helpers/validateCertificatePath.js");
|
|
10
|
+
const getCertificateInfo_js_1 = require("../../../helpers/getCertificateInfo.js");
|
|
11
|
+
const verifySignature_js_1 = require("../../../helpers/verifySignature.js");
|
|
12
|
+
const index_js_1 = require("../../../helpers/iso/index.js");
|
|
13
|
+
const metadataService_js_1 = require("../../../services/metadataService.js");
|
|
14
|
+
const verifyAttestationWithMetadata_js_1 = require("../../../metadata/verifyAttestationWithMetadata.js");
|
|
15
|
+
const constants_js_1 = require("./constants.js");
|
|
16
|
+
const parseCertInfo_js_1 = require("./parseCertInfo.js");
|
|
17
|
+
const parsePubArea_js_1 = require("./parsePubArea.js");
|
|
19
18
|
async function verifyAttestationTPM(options) {
|
|
20
|
-
|
|
21
|
-
const { aaguid, attStmt, authData, credentialPublicKey, clientDataHash, rootCertificates } = options;
|
|
19
|
+
const { aaguid, attStmt, authData, credentialPublicKey, clientDataHash, rootCertificates, } = options;
|
|
22
20
|
const ver = attStmt.get('ver');
|
|
23
21
|
const sig = attStmt.get('sig');
|
|
24
22
|
const alg = attStmt.get('alg');
|
|
@@ -37,7 +35,7 @@ async function verifyAttestationTPM(options) {
|
|
|
37
35
|
if (!alg) {
|
|
38
36
|
throw new Error(`Attestation statement did not contain alg (TPM)`);
|
|
39
37
|
}
|
|
40
|
-
if (!(0,
|
|
38
|
+
if (!(0, cose_js_1.isCOSEAlg)(alg)) {
|
|
41
39
|
throw new Error(`Attestation statement contained invalid alg ${alg} (TPM)`);
|
|
42
40
|
}
|
|
43
41
|
if (!x5c) {
|
|
@@ -49,24 +47,24 @@ async function verifyAttestationTPM(options) {
|
|
|
49
47
|
if (!certInfo) {
|
|
50
48
|
throw new Error('Attestation statement did not contain certInfo (TPM)');
|
|
51
49
|
}
|
|
52
|
-
const parsedPubArea = (0,
|
|
50
|
+
const parsedPubArea = (0, parsePubArea_js_1.parsePubArea)(pubArea);
|
|
53
51
|
const { unique, type: pubType, parameters } = parsedPubArea;
|
|
54
52
|
// Verify that the public key specified by the parameters and unique fields of pubArea is
|
|
55
53
|
// identical to the credentialPublicKey in the attestedCredentialData in authenticatorData.
|
|
56
|
-
const cosePublicKey = (0,
|
|
54
|
+
const cosePublicKey = (0, decodeCredentialPublicKey_js_1.decodeCredentialPublicKey)(credentialPublicKey);
|
|
57
55
|
if (pubType === 'TPM_ALG_RSA') {
|
|
58
|
-
if (!(0,
|
|
59
|
-
throw new Error(`Credential public key with kty ${cosePublicKey.get(
|
|
56
|
+
if (!(0, cose_js_1.isCOSEPublicKeyRSA)(cosePublicKey)) {
|
|
57
|
+
throw new Error(`Credential public key with kty ${cosePublicKey.get(cose_js_1.COSEKEYS.kty)} did not match ${pubType}`);
|
|
60
58
|
}
|
|
61
|
-
const n = cosePublicKey.get(
|
|
62
|
-
const e = cosePublicKey.get(
|
|
59
|
+
const n = cosePublicKey.get(cose_js_1.COSEKEYS.n);
|
|
60
|
+
const e = cosePublicKey.get(cose_js_1.COSEKEYS.e);
|
|
63
61
|
if (!n) {
|
|
64
62
|
throw new Error('COSE public key missing n (TPM|RSA)');
|
|
65
63
|
}
|
|
66
64
|
if (!e) {
|
|
67
65
|
throw new Error('COSE public key missing e (TPM|RSA)');
|
|
68
66
|
}
|
|
69
|
-
if (!
|
|
67
|
+
if (!index_js_1.isoUint8Array.areEqual(unique, n)) {
|
|
70
68
|
throw new Error('PubArea unique is not same as credentialPublicKey (TPM|RSA)');
|
|
71
69
|
}
|
|
72
70
|
if (!parameters.rsa) {
|
|
@@ -82,12 +80,12 @@ async function verifyAttestationTPM(options) {
|
|
|
82
80
|
}
|
|
83
81
|
}
|
|
84
82
|
else if (pubType === 'TPM_ALG_ECC') {
|
|
85
|
-
if (!(0,
|
|
86
|
-
throw new Error(`Credential public key with kty ${cosePublicKey.get(
|
|
83
|
+
if (!(0, cose_js_1.isCOSEPublicKeyEC2)(cosePublicKey)) {
|
|
84
|
+
throw new Error(`Credential public key with kty ${cosePublicKey.get(cose_js_1.COSEKEYS.kty)} did not match ${pubType}`);
|
|
87
85
|
}
|
|
88
|
-
const crv = cosePublicKey.get(
|
|
89
|
-
const x = cosePublicKey.get(
|
|
90
|
-
const y = cosePublicKey.get(
|
|
86
|
+
const crv = cosePublicKey.get(cose_js_1.COSEKEYS.crv);
|
|
87
|
+
const x = cosePublicKey.get(cose_js_1.COSEKEYS.x);
|
|
88
|
+
const y = cosePublicKey.get(cose_js_1.COSEKEYS.y);
|
|
91
89
|
if (!crv) {
|
|
92
90
|
throw new Error('COSE public key missing crv (TPM|ECC)');
|
|
93
91
|
}
|
|
@@ -97,14 +95,14 @@ async function verifyAttestationTPM(options) {
|
|
|
97
95
|
if (!y) {
|
|
98
96
|
throw new Error('COSE public key missing y (TPM|ECC)');
|
|
99
97
|
}
|
|
100
|
-
if (!
|
|
98
|
+
if (!index_js_1.isoUint8Array.areEqual(unique, index_js_1.isoUint8Array.concat([x, y]))) {
|
|
101
99
|
throw new Error('PubArea unique is not same as public key x and y (TPM|ECC)');
|
|
102
100
|
}
|
|
103
101
|
if (!parameters.ecc) {
|
|
104
102
|
throw new Error(`Parsed pubArea type is ECC, but missing parameters.ecc (TPM|ECC)`);
|
|
105
103
|
}
|
|
106
104
|
const pubAreaCurveID = parameters.ecc.curveID;
|
|
107
|
-
const pubAreaCurveIDMapToCOSECRV =
|
|
105
|
+
const pubAreaCurveIDMapToCOSECRV = constants_js_1.TPM_ECC_CURVE_COSE_CRV_MAP[pubAreaCurveID];
|
|
108
106
|
if (pubAreaCurveIDMapToCOSECRV !== crv) {
|
|
109
107
|
throw new Error(`Public area key curve ID "${pubAreaCurveID}" mapped to "${pubAreaCurveIDMapToCOSECRV}" which did not match public key crv of "${crv}" (TPM|ECC)`);
|
|
110
108
|
}
|
|
@@ -112,7 +110,7 @@ async function verifyAttestationTPM(options) {
|
|
|
112
110
|
else {
|
|
113
111
|
throw new Error(`Unsupported pubArea.type "${pubType}"`);
|
|
114
112
|
}
|
|
115
|
-
const parsedCertInfo = (0,
|
|
113
|
+
const parsedCertInfo = (0, parseCertInfo_js_1.parseCertInfo)(certInfo);
|
|
116
114
|
const { magic, type: certType, attested, extraData } = parsedCertInfo;
|
|
117
115
|
if (magic !== 0xff544347) {
|
|
118
116
|
throw new Error(`Unexpected magic value "${magic}", expected "0xff544347" (TPM)`);
|
|
@@ -121,19 +119,22 @@ async function verifyAttestationTPM(options) {
|
|
|
121
119
|
throw new Error(`Unexpected type "${certType}", expected "TPM_ST_ATTEST_CERTIFY" (TPM)`);
|
|
122
120
|
}
|
|
123
121
|
// Hash pubArea to create pubAreaHash using the nameAlg in attested
|
|
124
|
-
const pubAreaHash = await (0,
|
|
122
|
+
const pubAreaHash = await (0, toHash_js_1.toHash)(pubArea, attestedNameAlgToCOSEAlg(attested.nameAlg));
|
|
125
123
|
// Concatenate attested.nameAlg and pubAreaHash to create attestedName.
|
|
126
|
-
const attestedName =
|
|
124
|
+
const attestedName = index_js_1.isoUint8Array.concat([
|
|
125
|
+
attested.nameAlgBuffer,
|
|
126
|
+
pubAreaHash,
|
|
127
|
+
]);
|
|
127
128
|
// Check that certInfo.attested.name is equals to attestedName.
|
|
128
|
-
if (!
|
|
129
|
+
if (!index_js_1.isoUint8Array.areEqual(attested.name, attestedName)) {
|
|
129
130
|
throw new Error(`Attested name comparison failed (TPM)`);
|
|
130
131
|
}
|
|
131
132
|
// Concatenate authData with clientDataHash to create attToBeSigned
|
|
132
|
-
const attToBeSigned =
|
|
133
|
+
const attToBeSigned = index_js_1.isoUint8Array.concat([authData, clientDataHash]);
|
|
133
134
|
// Hash attToBeSigned using the algorithm specified in attStmt.alg to create attToBeSignedHash
|
|
134
|
-
const attToBeSignedHash = await (0,
|
|
135
|
+
const attToBeSignedHash = await (0, toHash_js_1.toHash)(attToBeSigned, alg);
|
|
135
136
|
// Check that certInfo.extraData is equals to attToBeSignedHash.
|
|
136
|
-
if (!
|
|
137
|
+
if (!index_js_1.isoUint8Array.areEqual(extraData, attToBeSignedHash)) {
|
|
137
138
|
throw new Error('CertInfo extra data did not equal hashed attestation (TPM)');
|
|
138
139
|
}
|
|
139
140
|
/**
|
|
@@ -143,7 +144,7 @@ async function verifyAttestationTPM(options) {
|
|
|
143
144
|
throw new Error('No certificates present in x5c array (TPM)');
|
|
144
145
|
}
|
|
145
146
|
// Pick a leaf AIK certificate of the x5c array and parse it.
|
|
146
|
-
const leafCertInfo = (0,
|
|
147
|
+
const leafCertInfo = (0, getCertificateInfo_js_1.getCertificateInfo)(x5c[0]);
|
|
147
148
|
const { basicConstraintsCA, version, subject, notAfter, notBefore } = leafCertInfo;
|
|
148
149
|
if (basicConstraintsCA) {
|
|
149
150
|
throw new Error('Certificate basic constraints CA was not `false` (TPM)');
|
|
@@ -169,18 +170,18 @@ async function verifyAttestationTPM(options) {
|
|
|
169
170
|
/**
|
|
170
171
|
* Plumb the depths of the certificate's ASN.1-formatted data for some values we need to verify
|
|
171
172
|
*/
|
|
172
|
-
const parsedCert =
|
|
173
|
+
const parsedCert = deps_js_1.AsnParser.parse(x5c[0], deps_js_1.Certificate);
|
|
173
174
|
if (!parsedCert.tbsCertificate.extensions) {
|
|
174
175
|
throw new Error('Certificate was missing extensions (TPM)');
|
|
175
176
|
}
|
|
176
177
|
let subjectAltNamePresent;
|
|
177
178
|
let extKeyUsage;
|
|
178
|
-
parsedCert.tbsCertificate.extensions.forEach(ext => {
|
|
179
|
-
if (ext.extnID ===
|
|
180
|
-
subjectAltNamePresent =
|
|
179
|
+
parsedCert.tbsCertificate.extensions.forEach((ext) => {
|
|
180
|
+
if (ext.extnID === deps_js_1.id_ce_subjectAltName) {
|
|
181
|
+
subjectAltNamePresent = deps_js_1.AsnParser.parse(ext.extnValue, deps_js_1.SubjectAlternativeName);
|
|
181
182
|
}
|
|
182
|
-
else if (ext.extnID ===
|
|
183
|
-
extKeyUsage =
|
|
183
|
+
else if (ext.extnID === deps_js_1.id_ce_extKeyUsage) {
|
|
184
|
+
extKeyUsage = deps_js_1.AsnParser.parse(ext.extnValue, deps_js_1.ExtendedKeyUsage);
|
|
184
185
|
}
|
|
185
186
|
});
|
|
186
187
|
// Check that certificate contains subjectAltName (2.5.29.17) extension,
|
|
@@ -189,7 +190,7 @@ async function verifyAttestationTPM(options) {
|
|
|
189
190
|
}
|
|
190
191
|
// TPM-specific values are buried within `directoryName`, so first make sure there are values
|
|
191
192
|
// there.
|
|
192
|
-
if (!
|
|
193
|
+
if (!subjectAltNamePresent[0].directoryName?.[0].length) {
|
|
193
194
|
throw new Error('Certificate subjectAltName extension directoryName was empty (TPM)');
|
|
194
195
|
}
|
|
195
196
|
const { tcgAtTpmManufacturer, tcgAtTpmModel, tcgAtTpmVersion } = getTcgAtTpmValues(subjectAltNamePresent[0].directoryName);
|
|
@@ -200,7 +201,7 @@ async function verifyAttestationTPM(options) {
|
|
|
200
201
|
throw new Error('Certificate did not contain ExtendedKeyUsage extension (TPM)');
|
|
201
202
|
}
|
|
202
203
|
// Check that tcpaTpmManufacturer (2.23.133.2.1) field is set to a valid manufacturer ID.
|
|
203
|
-
if (!
|
|
204
|
+
if (!constants_js_1.TPM_MANUFACTURERS[tcgAtTpmManufacturer]) {
|
|
204
205
|
throw new Error(`Could not match TPM manufacturer "${tcgAtTpmManufacturer}" (TPM)`);
|
|
205
206
|
}
|
|
206
207
|
// Check that certificate contains extKeyUsage (2.5.29.37) extension and it must contain
|
|
@@ -211,10 +212,10 @@ async function verifyAttestationTPM(options) {
|
|
|
211
212
|
// TODO: If certificate contains id-fido-gen-ce-aaguid(1.3.6.1.4.1.45724.1.1.4) extension, check
|
|
212
213
|
// that it’s value is set to the same AAGUID as in authData.
|
|
213
214
|
// Run some metadata checks if a statement exists for this authenticator
|
|
214
|
-
const statement = await
|
|
215
|
+
const statement = await metadataService_js_1.MetadataService.getStatement(aaguid);
|
|
215
216
|
if (statement) {
|
|
216
217
|
try {
|
|
217
|
-
await (0,
|
|
218
|
+
await (0, verifyAttestationWithMetadata_js_1.verifyAttestationWithMetadata)({
|
|
218
219
|
statement,
|
|
219
220
|
credentialPublicKey,
|
|
220
221
|
x5c,
|
|
@@ -229,7 +230,7 @@ async function verifyAttestationTPM(options) {
|
|
|
229
230
|
else {
|
|
230
231
|
try {
|
|
231
232
|
// Try validating the certificate path using the root certificates set via SettingsService
|
|
232
|
-
await (0,
|
|
233
|
+
await (0, validateCertificatePath_js_1.validateCertificatePath)(x5c.map(convertCertBufferToPEM_js_1.convertCertBufferToPEM), rootCertificates);
|
|
233
234
|
}
|
|
234
235
|
catch (err) {
|
|
235
236
|
const _err = err;
|
|
@@ -238,7 +239,7 @@ async function verifyAttestationTPM(options) {
|
|
|
238
239
|
}
|
|
239
240
|
// Verify signature over certInfo with the public key extracted from AIK certificate.
|
|
240
241
|
// In the wise words of Yuriy Ackermann: "Get Martini friend, you are done!"
|
|
241
|
-
return (0,
|
|
242
|
+
return (0, verifySignature_js_1.verifySignature)({
|
|
242
243
|
signature: sig,
|
|
243
244
|
data: certInfo,
|
|
244
245
|
x509Certificate: x5c[0],
|
|
@@ -284,8 +285,8 @@ function getTcgAtTpmValues(root) {
|
|
|
284
285
|
*
|
|
285
286
|
* Both structures have been seen in the wild and need to be supported
|
|
286
287
|
*/
|
|
287
|
-
root.forEach(relName => {
|
|
288
|
-
relName.forEach(attr => {
|
|
288
|
+
root.forEach((relName) => {
|
|
289
|
+
relName.forEach((attr) => {
|
|
289
290
|
if (attr.type === oidManufacturer) {
|
|
290
291
|
tcgAtTpmManufacturer = attr.value.toString();
|
|
291
292
|
}
|
|
@@ -314,14 +315,13 @@ function getTcgAtTpmValues(root) {
|
|
|
314
315
|
*/
|
|
315
316
|
function attestedNameAlgToCOSEAlg(alg) {
|
|
316
317
|
if (alg === 'TPM_ALG_SHA256') {
|
|
317
|
-
return
|
|
318
|
+
return cose_js_1.COSEALG.ES256;
|
|
318
319
|
}
|
|
319
320
|
else if (alg === 'TPM_ALG_SHA384') {
|
|
320
|
-
return
|
|
321
|
+
return cose_js_1.COSEALG.ES384;
|
|
321
322
|
}
|
|
322
323
|
else if (alg === 'TPM_ALG_SHA512') {
|
|
323
|
-
return
|
|
324
|
+
return cose_js_1.COSEALG.ES512;
|
|
324
325
|
}
|
|
325
326
|
throw new Error(`Unexpected TPM attested name alg ${alg}`);
|
|
326
327
|
}
|
|
327
|
-
//# sourceMappingURL=verifyAttestationTPM.js.map
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.verifyAttestationAndroidKey = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const metadataService_1 = require("../../services/metadataService");
|
|
14
|
-
const verifyAttestationWithMetadata_1 = require("../../metadata/verifyAttestationWithMetadata");
|
|
4
|
+
const deps_js_1 = require("../../deps.js");
|
|
5
|
+
const convertCertBufferToPEM_js_1 = require("../../helpers/convertCertBufferToPEM.js");
|
|
6
|
+
const validateCertificatePath_js_1 = require("../../helpers/validateCertificatePath.js");
|
|
7
|
+
const verifySignature_js_1 = require("../../helpers/verifySignature.js");
|
|
8
|
+
const convertCOSEtoPKCS_js_1 = require("../../helpers/convertCOSEtoPKCS.js");
|
|
9
|
+
const cose_js_1 = require("../../helpers/cose.js");
|
|
10
|
+
const index_js_1 = require("../../helpers/iso/index.js");
|
|
11
|
+
const metadataService_js_1 = require("../../services/metadataService.js");
|
|
12
|
+
const verifyAttestationWithMetadata_js_1 = require("../../metadata/verifyAttestationWithMetadata.js");
|
|
15
13
|
/**
|
|
16
14
|
* Verify an attestation response with fmt 'android-key'
|
|
17
15
|
*/
|
|
18
16
|
async function verifyAttestationAndroidKey(options) {
|
|
19
|
-
|
|
20
|
-
const { authData, clientDataHash, attStmt, credentialPublicKey, aaguid, rootCertificates } = options;
|
|
17
|
+
const { authData, clientDataHash, attStmt, credentialPublicKey, aaguid, rootCertificates, } = options;
|
|
21
18
|
const x5c = attStmt.get('x5c');
|
|
22
19
|
const sig = attStmt.get('sig');
|
|
23
20
|
const alg = attStmt.get('alg');
|
|
@@ -30,27 +27,27 @@ async function verifyAttestationAndroidKey(options) {
|
|
|
30
27
|
if (!alg) {
|
|
31
28
|
throw new Error(`Attestation statement did not contain alg (AndroidKey)`);
|
|
32
29
|
}
|
|
33
|
-
if (!(0,
|
|
30
|
+
if (!(0, cose_js_1.isCOSEAlg)(alg)) {
|
|
34
31
|
throw new Error(`Attestation statement contained invalid alg ${alg} (AndroidKey)`);
|
|
35
32
|
}
|
|
36
33
|
// Check that credentialPublicKey matches the public key in the attestation certificate
|
|
37
34
|
// Find the public cert in the certificate as PKCS
|
|
38
|
-
const parsedCert =
|
|
35
|
+
const parsedCert = deps_js_1.AsnParser.parse(x5c[0], deps_js_1.Certificate);
|
|
39
36
|
const parsedCertPubKey = new Uint8Array(parsedCert.tbsCertificate.subjectPublicKeyInfo.subjectPublicKey);
|
|
40
37
|
// Convert the credentialPublicKey to PKCS
|
|
41
|
-
const credPubKeyPKCS = (0,
|
|
42
|
-
if (!
|
|
38
|
+
const credPubKeyPKCS = (0, convertCOSEtoPKCS_js_1.convertCOSEtoPKCS)(credentialPublicKey);
|
|
39
|
+
if (!index_js_1.isoUint8Array.areEqual(credPubKeyPKCS, parsedCertPubKey)) {
|
|
43
40
|
throw new Error('Credential public key does not equal leaf cert public key (AndroidKey)');
|
|
44
41
|
}
|
|
45
42
|
// Find Android KeyStore Extension in certificate extensions
|
|
46
|
-
const extKeyStore =
|
|
43
|
+
const extKeyStore = parsedCert.tbsCertificate.extensions?.find((ext) => ext.extnID === deps_js_1.id_ce_keyDescription);
|
|
47
44
|
if (!extKeyStore) {
|
|
48
45
|
throw new Error('Certificate did not contain extKeyStore (AndroidKey)');
|
|
49
46
|
}
|
|
50
|
-
const parsedExtKeyStore =
|
|
47
|
+
const parsedExtKeyStore = deps_js_1.AsnParser.parse(extKeyStore.extnValue, deps_js_1.KeyDescription);
|
|
51
48
|
// Verify extKeyStore values
|
|
52
49
|
const { attestationChallenge, teeEnforced, softwareEnforced } = parsedExtKeyStore;
|
|
53
|
-
if (!
|
|
50
|
+
if (!index_js_1.isoUint8Array.areEqual(new Uint8Array(attestationChallenge.buffer), clientDataHash)) {
|
|
54
51
|
throw new Error('Attestation challenge was not equal to client data hash (AndroidKey)');
|
|
55
52
|
}
|
|
56
53
|
// Ensure that the key is strictly bound to the caller app identifier (shouldn't contain the
|
|
@@ -61,10 +58,10 @@ async function verifyAttestationAndroidKey(options) {
|
|
|
61
58
|
if (softwareEnforced.allApplications !== undefined) {
|
|
62
59
|
throw new Error('teeEnforced contained "allApplications [600]" tag (AndroidKey)');
|
|
63
60
|
}
|
|
64
|
-
const statement = await
|
|
61
|
+
const statement = await metadataService_js_1.MetadataService.getStatement(aaguid);
|
|
65
62
|
if (statement) {
|
|
66
63
|
try {
|
|
67
|
-
await (0,
|
|
64
|
+
await (0, verifyAttestationWithMetadata_js_1.verifyAttestationWithMetadata)({
|
|
68
65
|
statement,
|
|
69
66
|
credentialPublicKey,
|
|
70
67
|
x5c,
|
|
@@ -79,15 +76,15 @@ async function verifyAttestationAndroidKey(options) {
|
|
|
79
76
|
else {
|
|
80
77
|
try {
|
|
81
78
|
// Try validating the certificate path using the root certificates set via SettingsService
|
|
82
|
-
await (0,
|
|
79
|
+
await (0, validateCertificatePath_js_1.validateCertificatePath)(x5c.map(convertCertBufferToPEM_js_1.convertCertBufferToPEM), rootCertificates);
|
|
83
80
|
}
|
|
84
81
|
catch (err) {
|
|
85
82
|
const _err = err;
|
|
86
83
|
throw new Error(`${_err.message} (AndroidKey)`);
|
|
87
84
|
}
|
|
88
85
|
}
|
|
89
|
-
const signatureBase =
|
|
90
|
-
return (0,
|
|
86
|
+
const signatureBase = index_js_1.isoUint8Array.concat([authData, clientDataHash]);
|
|
87
|
+
return (0, verifySignature_js_1.verifySignature)({
|
|
91
88
|
signature: sig,
|
|
92
89
|
data: signatureBase,
|
|
93
90
|
x509Certificate: x5c[0],
|
|
@@ -95,4 +92,3 @@ async function verifyAttestationAndroidKey(options) {
|
|
|
95
92
|
});
|
|
96
93
|
}
|
|
97
94
|
exports.verifyAttestationAndroidKey = verifyAttestationAndroidKey;
|
|
98
|
-
//# sourceMappingURL=verifyAttestationAndroidKey.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AttestationFormatVerifierOpts } from '../verifyRegistrationResponse.js';
|
|
2
|
+
/**
|
|
3
|
+
* Verify an attestation response with fmt 'android-safetynet'
|
|
4
|
+
*/
|
|
5
|
+
export declare function verifyAttestationAndroidSafetyNet(options: AttestationFormatVerifierOpts): Promise<boolean>;
|