internal static CoseHeaderMap GetHeaderMapWithAlgorithm(CoseAlgorithm algorithm = CoseAlgorithm.ES256) { var protectedHeaders = new CoseHeaderMap(); protectedHeaders.SetValue(CoseHeaderLabel.Algorithm, (int)algorithm); return(protectedHeaders); }
public CommonAttestation MarshalToPublic() { var algoStr = (HashAlgorithm == IntPtr.Zero ? null : Marshal.PtrToStringUni(HashAlgorithm)) ?? "ES256"; if (CoseAlgorithm == 0) { CoseAlgorithm = CoseAlgorithm.ECDSA_P256_WITH_SHA256; } var signature = new byte[SignatureBytes]; if (SignatureBytes > 0) { Marshal.Copy(Signature, signature, 0, SignatureBytes); } var certs = new List <X509Certificate2>(); var pos = X5c; var x5cStep = Marshal.SizeOf <RawWebAuthnX5C>(); for (var n = 0; n < X5cCount; n++) { var certBlock = Marshal.PtrToStructure <RawWebAuthnX5C>(pos); var data = new byte[certBlock.DataBytes]; Marshal.Copy(certBlock.Data, data, 0, certBlock.DataBytes); var decoded = new X509Certificate2(data); certs.Add(decoded); pos += x5cStep; } var tpmVersion = Marshal.PtrToStringUni(Version); var certInfo = new byte[CertInfoBytes]; if (CertInfoBytes > 0) { Marshal.Copy(CertInfo, certInfo, 0, CertInfoBytes); } var pubArea = new byte[PubAreaBytes]; if (PubAreaBytes > 0) { Marshal.Copy(PubArea, pubArea, 0, PubAreaBytes); } return(new CommonAttestation { Algorithm = algoStr, CoseAlgorithm = CoseAlgorithm, Signature = signature, Certificates = certs, TpmVersion = tpmVersion, TpmCertInfo = certInfo, TpmPubArea = pubArea }); }
internal static List <(CoseHeaderLabel, ReadOnlyMemory <byte>)> GetExpectedProtectedHeaders(CoseAlgorithm algorithm) { var l = new List <(CoseHeaderLabel, ReadOnlyMemory <byte>)>(); AddEncoded(l, CoseHeaderLabel.Algorithm, (int)algorithm); return(l); }
internal void AssertCoseSignMessage( ReadOnlySpan <byte> encodedMsg, ReadOnlySpan <byte> expectedContent, AsymmetricAlgorithm key, CoseAlgorithm algorithm, List <(CoseHeaderLabel, ReadOnlyMemory <byte>)>?expectedProtectedHeaders = null,
public CoseCredentialParameter(CoseAlgorithm algo) => Algorithm = algo;