Ejemplo n.º 1
0
 public static string[] tokenTANMatrixArrayFetch(TokenCryptoData tokenCryptoData, string masterKey, string dataEntropy)
 {
     string[] result;
     try
     {
         string[] array = BaseFunctions.DecodeFrom64(tokenCryptoData.CryptoData.SupportCryptoData).Split(new char[]
         {
             ';'
         });
         if (tokenCryptoData.TokenBaseParams.OTPValidationWindow != array.Length)
         {
             result = null;
         }
         else
         {
             byte[]   tokenSeed = tokenCryptoData.GetTokenSeed(masterKey);
             string[] array2    = new string[tokenCryptoData.TokenBaseParams.OTPValidationWindow];
             for (int i = 0; i < tokenCryptoData.TokenBaseParams.OTPValidationWindow; i++)
             {
                 tokenCryptoData.ResetMovingFactor((long)int.Parse(array[i]));
                 array2[i] = HOTPPwdGenerator.generate(tokenCryptoData, tokenSeed, (dataEntropy == null || dataEntropy.Length < 1) ? new byte[0] : BaseFunctions.convertStringToByteArray(dataEntropy));
             }
             result = array2;
         }
     }
     catch
     {
         LOGGER.Write(LOGGER.LogCategory.ERROR, "SF.Expand.SAF.Core::TANMatrixArrayFetch[]", null);
         result = null;
     }
     finally
     {
     }
     return(result);
 }
Ejemplo n.º 2
0
        public AutenticationStatus Autenticate(string tokenInternalID, string password, string dataEntropy, out string newChallenge)
        {
            newChallenge = null;
            TokenCryptoData     _tkCryptoData = new TokensDAO().loadTokenCryptoData(tokenInternalID);
            AutenticationStatus result;

            if (_tkCryptoData.ID == null)
            {
                result = AutenticationStatus.TokenNotFoundOrCanceled;
            }
            else
            {
                if (_tkCryptoData.TokenBaseParams.MovingFactorType != TokenMovingFactorType.TransactionAuthenticationNumber)
                {
                    throw new Exception("Function not implemented for this type of token!!");
                }
                string currentChallenge = (string)new TokensChallengeRequestDAO().loadChallengeRequest(tokenInternalID);
                if (currentChallenge == null)
                {
                    result = AutenticationStatus.InvalidDataOnPasswordValidation;
                }
                else
                {
                    int      iRequest       = int.Parse(SAFConfiguration.readParameterExternal("TANRequestPositions"));
                    int      iDigitsByPos   = int.Parse(SAFConfiguration.readParameterExternal("TANDigitsByPosition"));
                    int      iFixPosOnFaill = int.Parse(SAFConfiguration.readParameterExternal("TANFixedPosOnFail"));
                    string   _otp           = string.Empty;
                    byte[]   _tkSeedOpen    = BaseFunctions.HexDecoder(_tkCryptoData.CryptoData.CryptoKey.Trim());
                    byte[]   _dataEntropy   = (dataEntropy == null || dataEntropy.Length < 1) ? new byte[0] : BaseFunctions.convertStringToByteArray(dataEntropy);
                    string[] _arrayPosValid = currentChallenge.Split(new char[]
                    {
                        '|'
                    });
                    string[] _arrayChallenge = BaseFunctions.DecodeFrom64(_tkCryptoData.CryptoData.SupportCryptoData.Trim()).Split(new char[]
                    {
                        ';'
                    });
                    for (int idx = 0; idx < _arrayPosValid.Length; idx++)
                    {
                        string[] _temp = _arrayPosValid[idx].Trim().Split(new char[]
                        {
                            ';'
                        });
                        _tkCryptoData.ResetMovingFactor(long.Parse(_arrayChallenge[(int)checked ((IntPtr)long.Parse(_temp[0]))]));
                        _otp += HOTPPwdGenerator.generate(_tkCryptoData, _tkSeedOpen, _dataEntropy).Substring(int.Parse(_temp[1]), 1);
                    }
                    if (password.Trim() == _otp)
                    {
                        if (OperationResult.Success == new TokensChallengeRequestDAO().resetChallengeRequest(tokenInternalID))
                        {
                            result = AutenticationStatus.Success;
                            return(result);
                        }
                    }
                    result = AutenticationStatus.TokenOrPasswordInvalid;
                }
            }
            return(result);
        }
 public static string[] tokenTANMatrixArrayFetch(TokenCryptoData tokenCryptoData, string masterKey, string dataEntropy)
 {
     string[] result;
     try
     {
         string[] _TanChallenge = BaseFunctions.DecodeFrom64(tokenCryptoData.CryptoData.SupportCryptoData).Split(new char[]
         {
             ';'
         });
         if (tokenCryptoData.TokenBaseParams.OTPValidationWindow != _TanChallenge.Length)
         {
             result = null;
         }
         else
         {
             byte[]   _seedOpen = tokenCryptoData.GetTokenSeed(masterKey);
             string[] _matriz   = new string[tokenCryptoData.TokenBaseParams.OTPValidationWindow];
             for (int _index = 0; _index < tokenCryptoData.TokenBaseParams.OTPValidationWindow; _index++)
             {
                 tokenCryptoData.ResetMovingFactor((long)int.Parse(_TanChallenge[_index]));
                 _matriz[_index] = HOTPPwdGenerator.generate(tokenCryptoData, _seedOpen, (dataEntropy == null || dataEntropy.Length < 1) ? new byte[0] : BaseFunctions.convertStringToByteArray(dataEntropy));
             }
             result = _matriz;
         }
     }
     catch (Exception ex)
     {
         SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
         {
             "http://sfexpand.SAFCore.TokensBaseFunctions.softfinanca.com/",
             Assembly.GetExecutingAssembly().FullName.ToString(),
             ex.ToString()
         });
         result = null;
     }
     finally
     {
     }
     return(result);
 }