Пример #1
0
        public bool IsEquelKey(AuthorityClassification role, KeyPair key)
        {
            switch (role)
            {
            case AuthorityClassification.Active:
                if (!Active.IsNull() && !Active.KeyAuths.IsNull())
                {
                    foreach (var keyAuth in Active.KeyAuths)
                    {
                        if (key.Equals(keyAuth.Key))
                        {
                            CustomTools.Console.DebugLog(CustomTools.Console.LogGreenColor("Active->", key.Public, "\n            Active<-", keyAuth.Key));
                            return(true);
                        }
                        CustomTools.Console.DebugLog(CustomTools.Console.LogRedColor("generated_key Active->", key.Public, "\ngetted_key        Active<-", keyAuth.Key));
                    }
                }
                return(false);

            case AuthorityClassification.Echorand:
                if (!EchorandKey.IsNull())
                {
                    if (key.Equals(EchorandKey))
                    {
                        CustomTools.Console.DebugLog(CustomTools.Console.LogGreenColor("Echorand->", key.Public, "\n            Echorand<-", EchorandKey));
                        return(true);
                    }
                    CustomTools.Console.DebugLog(CustomTools.Console.LogRedColor("generated_key Echorand->", key.Public, "\ngetted_key        Echorand<-", EchorandKey));
                }
                return(false);

            default:
                return(false);
            }
        }
Пример #2
0
 private byte[] GetRoleData(AuthorityClassification role)
 {
     if (role.Equals(AuthorityClassification.Active))
     {
         return(Encoding.UTF8.GetBytes(ACTIVE_KEY));
     }
     if (role.Equals(AuthorityClassification.Echorand))
     {
         return(Encoding.UTF8.GetBytes(ECHORAND_KEY));
     }
     return(new byte[0]);
 }
Пример #3
0
        public KeyPair(AuthorityClassification role, string userName, IPass password, IPrivateKeyFactory factory)
        {
            var buffer = new ByteBuffer(ByteBuffer.LITTLE_ENDING);
            var data   = Encoding.UTF8.GetBytes(userName.Trim());

            buffer.WriteBytes(data, false);
            data.Clear();
            data = GetRoleData(role);
            buffer.WriteBytes(data, false);
            data.Clear();
            data = password.Get();
            buffer.WriteBytes(data, false);
            data.Clear();
            var seed = buffer.ToArray();

            buffer.Dispose();
            privateKey = factory.FromSeed(seed);
            seed.Clear();
        }
Пример #4
0
        public bool IsEquelKey(AuthorityClassification role, KeyPair key)
        {
            switch (role)
            {
            case AuthorityClassification.Active:
                if (Active != null && Active.KeyAuths != null)
                {
                    foreach (var keyAuth in Active.KeyAuths)
                    {
                        if (key.Equals(keyAuth.Key))
                        {
                            return(true);
                        }
                    }
                }
                return(false);

            case AuthorityClassification.Echorand:
                return(key.Equals(EchorandKey));

            default:
                return(false);
            }
        }
Пример #5
0
 public IPublicKey this[AuthorityClassification role] => keys.ContainsKey(role) ? keys[role].Public : null;