internal static extern HRESULT WebAuthNAuthenticatorGetAssertion(
     [In] IntPtr hWnd,
     [MarshalAs(UnmanagedType.LPWStr)]
     [In] string pwszRpId,
     [In] ref WEBAUTHN_CLIENT_DATA pWebAuthNClientData,
     [In] ref WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS pWebAuthNGetAssertionOptions,
     [Out] out IntPtr ppWebAuthNAssertion);
Esempio n. 2
0
 internal static extern WebAuthnResult WebAuthNAuthenticatorGetAssertion(
     [In] IntPtr hWnd,
     [In, Optional] string rpId,
     [In] WEBAUTHN_CLIENT_DATA pWebAuthNClientData,
     [In, Optional] WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS pWebAuthNGetAssertionOptions,
     [Out] out IntPtr ppWebAuthNAssertion);
Esempio n. 3
0
        static void Main(string[] args)
        {
            var ver = WebAuthNGetApiVersionNumber();

            WebAuthNIsUserVerifyingPlatformAuthenticatorAvailable(out var available);
            var rp = new WEBAUTHN_RP_ENTITY_INFORMATION
            {
                Version = WEBAUTHN_RP_ENTITY_INFORMATION_CURRENT_VERSION,
                Id      = "login.windows.net",
                Name    = "login dot windows dot net",
            };

            var strAseigler = Marshal.StringToHGlobalUni("aseigler");

            var userEntity = new WEBAUTHN_USER_ENTITY_INFORMATION
            {
                Version     = WEBAUTHN_USER_ENTITY_INFORMATION_CURRENT_VERSION,
                Id          = strAseigler,
                IdLen       = Marshal.SizeOf(strAseigler),
                DisplayName = "Alex Seigler",
                Name        = "aseigler"
            };

            var coseParams        = new WEBAUTHN_COSE_CREDENTIAL_PARAMETER[0];
            var excludedCreds     = new WEBAUTHN_CREDENTIAL_EX[0];
            var excludedCredsList = new WEBAUTHN_CREDENTIAL_LIST[0];

            var webAuthNClientData = new WEBAUTHN_CLIENT_DATA
            {
                Version   = WEBAUTHN_CLIENT_DATA_CURRENT_VERSION,
                HashAlgId = WEBAUTHN_HASH_ALGORITHM_SHA_256,
            };

            const string challenge = "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wZWQgb3ZlciB0aGUgbGF6eSBkb2cu";
            const string hashAlg   = "SHA-256";
            const string origin    = "login.windows.net";

            webAuthNClientData.ClientDataJSON    = Marshal.StringToHGlobalUni(String.Format("{{\"challenge\":\"{0}\",\"clientExtensions\":\"{{}}\",\"hashAlgorithm\":\"{1}\",\"origin\":\"{2}\",\"type\":\"webauthn.create\"}}", challenge, hashAlg, origin));
            webAuthNClientData.ClientDataJSONLen = Marshal.SizeOf(webAuthNClientData.ClientDataJSON);

            var webAuthNMakeCredentialOptions = new WEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS
            {
                Version                         = WEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS_CURRENT_VERSION,
                TimeoutMilliseconds             = 60000,
                AuthenticatorAttachment         = WEBAUTHN_AUTHENTICATOR_ATTACHMENT_ANY,
                RequireResidentKey              = false,
                UserVerificationRequirement     = WEBAUTHN_USER_VERIFICATION_REQUIREMENT_ANY,
                AttestationConveyancePreference = WEBAUTHN_ATTESTATION_CONVEYANCE_PREFERENCE_ANY,
                Flags = 0,
            };

            var coseParam = new WEBAUTHN_COSE_CREDENTIAL_PARAMETER
            {
                Version        = WEBAUTHN_COSE_CREDENTIAL_PARAMETER_CURRENT_VERSION,
                Alg            = WEBAUTHN_COSE_ALGORITHM_ECDSA_P256_WITH_SHA256,
                CredentialType = WEBAUTHN_CREDENTIAL_TYPE_PUBLIC_KEY,
            };

            var param = new IntPtr();

            Marshal.StructureToPtr(coseParam, param, false);

            var pubKeyCredParams = new WEBAUTHN_COSE_CREDENTIAL_PARAMETERS
            {
                CredentialParameters       = param,
                CredentialParametersLength = Marshal.SizeOf(param),
            };

            var pWebAuthNCredentialAttestation = new WEBAUTHN_CREDENTIAL_ATTESTATION();
            //var hr = WebAuthNAuthenticatorMakeCredential(
            //GetForegroundWindow(), &rPInformation, &userInformation, &pubKeyCredParams,
            //&webAuthNClientData, &webAuthNMakeCredentialOptions,
            //&pWebAuthNCredentialAttestation);
        }