Example #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);
 }
        public static OperationResult Synchronize(TokenCryptoData tokenCryptoData, byte[] entropy, string masterKey, string firstPwd, string secondPwd, out long movingFactor)
        {
            long num  = tokenCryptoData.CryptoData.MovingFactor;
            int  num2 = 0;

            while ((long)num2 < tokenCryptoData.TokenBaseParams.HOTPValidationWindow4Sync)
            {
                try
                {
                    if (firstPwd.Equals(HOTPPwdGenerator.generate(tokenCryptoData, masterKey, entropy)))
                    {
                        AutenticationStatus autenticationStatus = (num > tokenCryptoData.CryptoData.MovingFactor) ? AutenticationStatus.SuccessButSynchronized : AutenticationStatus.Success;
                        if (autenticationStatus == AutenticationStatus.Success || autenticationStatus == AutenticationStatus.SuccessButSynchronized)
                        {
                            num += tokenCryptoData.TokenBaseParams.HOTPMovingFactorDrift;
                            if (firstPwd.Equals(HOTPPwdGenerator.generate(tokenCryptoData, masterKey, entropy)) && num <= tokenCryptoData.CryptoData.MovingFactor)
                            {
                                num = (movingFactor = num + tokenCryptoData.TokenBaseParams.HOTPMovingFactorDrift);
                                return(OperationResult.Success);
                            }
                        }
                    }
                    num += tokenCryptoData.TokenBaseParams.HOTPMovingFactorDrift;
                }
                catch (Exception)
                {
                    LOGGER.Write(LOGGER.LogCategory.ERROR, "SF.Expand.SAF.Core.HOTPPwdValidator::Synchronize[]", null);
                }
                num2++;
            }
            movingFactor = tokenCryptoData.CryptoData.MovingFactor;
            return(OperationResult.Error);
        }
        public static AutenticationStatus Validate(TokenCryptoData tokenCryptoData, byte[] entropy, string masterKey, string validatePwd, out long movingFactor)
        {
            long num = tokenCryptoData.CryptoData.MovingFactor;

            for (int i = 0; i < tokenCryptoData.TokenBaseParams.OTPValidationWindow; i++)
            {
                try
                {
                    if (validatePwd.Equals(HOTPPwdGenerator.generate(tokenCryptoData, masterKey, entropy)))
                    {
                        AutenticationStatus autenticationStatus = (num > tokenCryptoData.CryptoData.MovingFactor) ? AutenticationStatus.SuccessButSynchronized : AutenticationStatus.Success;
                        if (autenticationStatus == AutenticationStatus.Success || autenticationStatus == AutenticationStatus.SuccessButSynchronized)
                        {
                            num = (movingFactor = num + tokenCryptoData.TokenBaseParams.HOTPMovingFactorDrift);
                            return(autenticationStatus);
                        }
                    }
                    num += tokenCryptoData.TokenBaseParams.HOTPMovingFactorDrift;
                }
                catch (Exception)
                {
                    LOGGER.Write(LOGGER.LogCategory.ERROR, "SF.Expand.SAF.Core.HOTPPwdValidator::validate[]", null);
                }
            }
            movingFactor = tokenCryptoData.CryptoData.MovingFactor;
            return(AutenticationStatus.TokenOrPasswordInvalid);
        }
Example #4
0
        public static AutenticationStatus Validate(TokenCryptoData tokenCryptoData, byte[] entropy, string masterKey, string validatePwd, out long movingFactor)
        {
            long _initialMovingFactor = tokenCryptoData.CryptoData.MovingFactor;
            AutenticationStatus result;

            for (int i = 0; i < tokenCryptoData.TokenBaseParams.OTPValidationWindow; i++)
            {
                try
                {
                    if (validatePwd.Equals(HOTPPwdGenerator.generate(tokenCryptoData, masterKey, entropy)))
                    {
                        AutenticationStatus authStatus = (tokenCryptoData.CryptoData.MovingFactor > _initialMovingFactor) ? AutenticationStatus.SuccessButSynchronized : AutenticationStatus.Success;
                        movingFactor = tokenCryptoData.CryptoData.MovingFactor + tokenCryptoData.TokenBaseParams.HOTPMovingFactorDrift;
                        result       = authStatus;
                        return(result);
                    }
                    movingFactor = tokenCryptoData.CryptoData.MovingFactor + tokenCryptoData.TokenBaseParams.HOTPMovingFactorDrift;
                    tokenCryptoData.ResetMovingFactor(movingFactor);
                }
                catch (Exception ex)
                {
                    SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
                    {
                        "http://sfexpand.SAFCore.HOTPPwdValidator.softfinanca.com/",
                        ex.ToString()
                    });
                }
            }
            tokenCryptoData.ResetMovingFactor(_initialMovingFactor);
            movingFactor = _initialMovingFactor;
            result       = AutenticationStatus.TokenOrPasswordInvalid;
            return(result);
        }
        public static OperationResult tokenTANMatrixIntegrityCheck(TokenCryptoData tokenCryptoData, byte[] tkSeed, byte[] entropy, out string SupportCriptoData)
        {
            string          _TanMatrixChallenge = string.Empty;
            OperationResult result;

            try
            {
                string[] _matriz = new string[tokenCryptoData.TokenBaseParams.OTPValidationWindow];
                for (int _idx = 0; _idx < tokenCryptoData.TokenBaseParams.OTPValidationWindow; _idx++)
                {
                    bool _flag;
                    do
                    {
                        _flag = false;
                        tokenCryptoData.ResetMovingFactor(tokenCryptoData.CryptoData.MovingFactor + tokenCryptoData.TokenBaseParams.HOTPMovingFactorDrift);
                        _matriz[_idx] = HOTPPwdGenerator.generate(tokenCryptoData, tkSeed, new byte[0]);
                        for (int _idx2 = 0; _idx2 < _idx; _idx2++)
                        {
                            if (_matriz[_idx] == _matriz[_idx2])
                            {
                                _flag = true;
                                break;
                            }
                        }
                    }while (_flag);
                    _TanMatrixChallenge = _TanMatrixChallenge + _matriz[_idx] + ";";
                }
                SupportCriptoData = BaseFunctions.EncodeTo64(_TanMatrixChallenge.Substring(0, _TanMatrixChallenge.Length - 1));
                result            = OperationResult.Success;
            }
            catch (Exception ex)
            {
                SupportCriptoData = null;
                SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
                {
                    "http://sfexpand.SAFCore.TokensBaseFunctions.softfinanca.com/",
                    Assembly.GetExecutingAssembly().FullName.ToString(),
                    ex.ToString()
                });
                result = OperationResult.Error;
            }
            finally
            {
            }
            return(result);
        }
Example #6
0
        public static OperationResult Synchronize(TokenCryptoData tokenCryptoData, byte[] entropy, string masterKey, string firstPwd, string secondPwd, out long movingFactor)
        {
            long            _movingFactor = tokenCryptoData.CryptoData.MovingFactor;
            int             i             = 0;
            OperationResult result;

            while ((long)i < tokenCryptoData.TokenBaseParams.HOTPValidationWindow4Sync)
            {
                try
                {
                    if (firstPwd.Equals(HOTPPwdGenerator.generate(tokenCryptoData, masterKey, entropy)))
                    {
                        AutenticationStatus _authStatus = (_movingFactor > tokenCryptoData.CryptoData.MovingFactor) ? AutenticationStatus.SuccessButSynchronized : AutenticationStatus.Success;
                        if (_authStatus == AutenticationStatus.Success || _authStatus == AutenticationStatus.SuccessButSynchronized)
                        {
                            _movingFactor += tokenCryptoData.TokenBaseParams.HOTPMovingFactorDrift;
                            if (firstPwd.Equals(HOTPPwdGenerator.generate(tokenCryptoData, masterKey, entropy)))
                            {
                                _authStatus = ((_movingFactor > tokenCryptoData.CryptoData.MovingFactor) ? AutenticationStatus.SuccessButSynchronized : AutenticationStatus.Success);
                                if (_authStatus == AutenticationStatus.Success)
                                {
                                    _movingFactor = (movingFactor = _movingFactor + tokenCryptoData.TokenBaseParams.HOTPMovingFactorDrift);
                                    result        = OperationResult.Success;
                                    return(result);
                                }
                            }
                        }
                    }
                    _movingFactor += tokenCryptoData.TokenBaseParams.HOTPMovingFactorDrift;
                }
                catch (Exception ex)
                {
                    SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
                    {
                        "http://sfexpand.SAFCore.HOTPPwdValidator.softfinanca.com/",
                        Assembly.GetExecutingAssembly().FullName.ToString(),
                        ex.ToString()
                    });
                }
                i++;
            }
            movingFactor = tokenCryptoData.CryptoData.MovingFactor;
            result       = OperationResult.Error;
            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);
 }
Example #8
0
        public static OperationResult tokenTANMatrixIntegrityCheck(TokenCryptoData tokenCryptoData, byte[] tkSeed, byte[] entropy, out string SupportCriptoData)
        {
            OperationResult result;

            try
            {
                string   text  = string.Empty;
                string[] array = new string[tokenCryptoData.TokenBaseParams.OTPValidationWindow];
                for (int i = 0; i < tokenCryptoData.TokenBaseParams.OTPValidationWindow; i++)
                {
                    bool flag;
                    do
                    {
                        flag = false;
                        tokenCryptoData.ResetMovingFactor(tokenCryptoData.CryptoData.MovingFactor + tokenCryptoData.TokenBaseParams.HOTPMovingFactorDrift);
                        array[i] = HOTPPwdGenerator.generate(tokenCryptoData, tkSeed, new byte[0]);
                        for (int j = 0; j < i; j++)
                        {
                            if (array[i] == array[j])
                            {
                                flag = true;
                                break;
                            }
                        }
                    }while (flag);
                    text = text + array[i] + ";";
                }
                SupportCriptoData = BaseFunctions.EncodeTo64(text.Substring(0, text.Length - 1));
                result            = OperationResult.Success;
            }
            catch
            {
                LOGGER.Write(LOGGER.LogCategory.ERROR, "SF.Expand.SAF.Core::TANMatrixIntegrityCheck[]", null);
                SupportCriptoData = null;
                result            = OperationResult.Error;
            }
            return(result);
        }
Example #9
0
 public static string generate(TokenCryptoData tokenCryptoData, string masterKey, byte[] entropy)
 {
     return(HOTPPwdGenerator.generate(tokenCryptoData, tokenCryptoData.GetTokenSeed(masterKey), entropy));
 }