Esempio n. 1
0
 public static OmniDigitalSignature Create(string name, OmniDigitalSignatureAlgorithmType algorithmType)
 {
     if (algorithmType == OmniDigitalSignatureAlgorithmType.EcDsa_P521_Sha2_256)
     {
         var(publicKey, privateKey) = EcDsa_P521_Sha2_256.CreateKeys();
         return(new OmniDigitalSignature(name, algorithmType, publicKey, privateKey));
     }
     else
     {
         throw new NotSupportedException(nameof(algorithmType));
     }
 }
Esempio n. 2
0
            public OmniDigitalSignature Deserialize(Omnix.Serialization.RocketPack.RocketPackReader r, int rank)
            {
                if (rank > 256)
                {
                    throw new System.FormatException();
                }

                // Read property count
                uint propertyCount = r.GetUInt32();

                string p_name = string.Empty;
                OmniDigitalSignatureAlgorithmType p_algorithmType = (OmniDigitalSignatureAlgorithmType)0;

                System.ReadOnlyMemory <byte> p_publicKey  = System.ReadOnlyMemory <byte> .Empty;
                System.ReadOnlyMemory <byte> p_privateKey = System.ReadOnlyMemory <byte> .Empty;

                for (; propertyCount > 0; propertyCount--)
                {
                    uint id = r.GetUInt32();
                    switch (id)
                    {
                    case 0:     // Name
                    {
                        p_name = r.GetString(32);
                        break;
                    }

                    case 1:     // AlgorithmType
                    {
                        p_algorithmType = (OmniDigitalSignatureAlgorithmType)r.GetUInt64();
                        break;
                    }

                    case 2:     // PublicKey
                    {
                        p_publicKey = r.GetMemory(8192);
                        break;
                    }

                    case 3:     // PrivateKey
                    {
                        p_privateKey = r.GetMemory(8192);
                        break;
                    }
                    }
                }

                return(new OmniDigitalSignature(p_name, p_algorithmType, p_publicKey, p_privateKey));
            }
Esempio n. 3
0
        public OmniCertificate(string name, OmniDigitalSignatureAlgorithmType algorithmType, System.ReadOnlyMemory <byte> publicKey, System.ReadOnlyMemory <byte> value)
        {
            if (name is null)
            {
                throw new System.ArgumentNullException("name");
            }
            if (name.Length > 32)
            {
                throw new System.ArgumentOutOfRangeException("name");
            }
            if (publicKey.Length > 8192)
            {
                throw new System.ArgumentOutOfRangeException("publicKey");
            }
            if (value.Length > 8192)
            {
                throw new System.ArgumentOutOfRangeException("value");
            }

            this.Name          = name;
            this.AlgorithmType = algorithmType;
            this.PublicKey     = publicKey;
            this.Value         = value;

            {
                var __h = new System.HashCode();
                if (this.Name != default)
                {
                    __h.Add(this.Name.GetHashCode());
                }
                if (this.AlgorithmType != default)
                {
                    __h.Add(this.AlgorithmType.GetHashCode());
                }
                if (!this.PublicKey.IsEmpty)
                {
                    __h.Add(Omnix.Base.Helpers.ObjectHelper.GetHashCode(this.PublicKey.Span));
                }
                if (!this.Value.IsEmpty)
                {
                    __h.Add(Omnix.Base.Helpers.ObjectHelper.GetHashCode(this.Value.Span));
                }
                __hashCode = __h.ToHashCode();
            }
        }