コード例 #1
0
        ServerPublicKeyCredentialCreationOptionsResponse IFidoServer.GetAssertionOptions(
            ServerPublicKeyCredentialCreationOptionsRequest serverPublicKeyCredentialCreationOptionsRequest)
        {
            ServerPublicKeyCredentialCreationOptionsResponse response =
                new ServerPublicKeyCredentialCreationOptionsResponse();

            List <ServerPublicKeyCredentialDescriptor> allowCredentials = new List <ServerPublicKeyCredentialDescriptor>();

            foreach (ServerRegInfo info in regInfos)
            {
                ServerPublicKeyCredentialDescriptor desc = new ServerPublicKeyCredentialDescriptor();
                desc.Id   = info.CredentialId;
                desc.Type = "public-key";
                allowCredentials.Add(desc);
            }
            response.AllowCredentials = allowCredentials.ToArray();

            response.Challenge = ByteUtils.ByteToBase64(GetChallege());

            response.RpId = "www.huawei.fidodemo";

            response.Timeout = 60L;

            return(response);
        }
コード例 #2
0
        ServerPublicKeyCredentialCreationOptionsResponse IFidoServer.GetAttestationOptions(ServerPublicKeyCredentialCreationOptionsRequest request)
        {
            ServerPublicKeyCredentialCreationOptionsResponse response =
                new ServerPublicKeyCredentialCreationOptionsResponse();

            response.Attestation = request.Attestation;

            ServerAuthenticatorSelectionCriteria selectionCriteria = request.AuthenticatorSelection;

            if (selectionCriteria != null)
            {
                response.AuthenticatorSelection = selectionCriteria;
            }

            response.Challenge = ByteUtils.ByteToBase64(GetChallege());

            List <ServerPublicKeyCredentialDescriptor> excludeCredentialList = new List <ServerPublicKeyCredentialDescriptor>();

            foreach (ServerRegInfo info in regInfos)
            {
                ServerPublicKeyCredentialDescriptor desc = new ServerPublicKeyCredentialDescriptor();
                desc.Id   = info.CredentialId;
                desc.Type = "public-key";
                excludeCredentialList.Add(desc);
            }
            response.ExcludeCredentials = excludeCredentialList.ToArray();

            List <ServerPublicKeyCredentialParameters> pubKeyCredParamList = new List <ServerPublicKeyCredentialParameters>();
            ServerPublicKeyCredentialParameters        cp = new ServerPublicKeyCredentialParameters();

            cp.Alg  = -7;
            cp.Type = "public-key";
            pubKeyCredParamList.Add(cp);
            cp      = new ServerPublicKeyCredentialParameters();
            cp.Alg  = -257;
            cp.Type = "public-key";
            pubKeyCredParamList.Add(cp);
            response.PubKeyCredParams = pubKeyCredParamList.ToArray();

            ServerPublicKeyCredentialRpEntity rpEntity = new ServerPublicKeyCredentialRpEntity();

            rpEntity.Name = "www.huawei.fidodemo";
            response.Rp   = rpEntity;

            response.RpId = "www.huawei.fidodemo";

            response.Timeout = 60L;
            ServerPublicKeyCredentialUserEntity user = new ServerPublicKeyCredentialUserEntity();

            user.Id          = request.Username;
            user.DisplayName = request.DisplayName;
            response.User    = user;
            return(response);
        }