Exemplo n.º 1
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));
            }
Exemplo n.º 2
0
            public OmniAgreement Deserialize(Omnix.Serialization.RocketPack.RocketPackReader r, int rank)
            {
                if (rank > 256)
                {
                    throw new System.FormatException();
                }

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

                Omnix.Serialization.RocketPack.Timestamp p_creationTime = Omnix.Serialization.RocketPack.Timestamp.Zero;
                OmniAgreementAlgorithmType p_algorithmType = (OmniAgreementAlgorithmType)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:     // CreationTime
                    {
                        p_creationTime = r.GetTimestamp();
                        break;
                    }

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

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

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

                return(new OmniAgreement(p_creationTime, p_algorithmType, p_publicKey, p_privateKey));
            }
Exemplo n.º 3
0
            public AuthenticationMessage Deserialize(Omnix.Serialization.RocketPack.RocketPackReader r, int rank)
            {
                if (rank > 256)
                {
                    throw new System.FormatException();
                }

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

                System.ReadOnlyMemory <byte>[] p_hashes = System.Array.Empty <System.ReadOnlyMemory <byte> >();

                for (; propertyCount > 0; propertyCount--)
                {
                    uint id = r.GetUInt32();
                    switch (id)
                    {
                    case 0:     // Hashes
                    {
                        var length = r.GetUInt32();
                        p_hashes = new System.ReadOnlyMemory <byte> [length];
                        for (int i = 0; i < p_hashes.Length; i++)
                        {
                            p_hashes[i] = r.GetMemory(32);
                        }
                        break;
                    }
                    }
                }

                return(new AuthenticationMessage(p_hashes));
            }
Exemplo n.º 4
0
            public OmniHashcash Deserialize(Omnix.Serialization.RocketPack.RocketPackReader r, int rank)
            {
                if (rank > 256)
                {
                    throw new System.FormatException();
                }

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

                OmniHashcashAlgorithmType p_algorithmType = (OmniHashcashAlgorithmType)0;

                System.ReadOnlyMemory <byte> p_key = System.ReadOnlyMemory <byte> .Empty;

                for (; propertyCount > 0; propertyCount--)
                {
                    uint id = r.GetUInt32();
                    switch (id)
                    {
                    case 0:     // AlgorithmType
                    {
                        p_algorithmType = (OmniHashcashAlgorithmType)r.GetUInt64();
                        break;
                    }

                    case 1:     // Key
                    {
                        p_key = r.GetMemory(32);
                        break;
                    }
                    }
                }

                return(new OmniHashcash(p_algorithmType, p_key));
            }
Exemplo n.º 5
0
            public OmniHash Deserialize(Omnix.Serialization.RocketPack.RocketPackReader r, int rank)
            {
                if (rank > 256)
                {
                    throw new System.FormatException();
                }

                OmniHashAlgorithmType p_algorithmType = (OmniHashAlgorithmType)0;

                System.ReadOnlyMemory <byte> p_value = System.ReadOnlyMemory <byte> .Empty;

                {
                    p_algorithmType = (OmniHashAlgorithmType)r.GetUInt64();
                }
                {
                    p_value = r.GetMemory(256);
                }
                return(new OmniHash(p_algorithmType, p_value));
            }
Exemplo n.º 6
0
            public ProfileMessage Deserialize(Omnix.Serialization.RocketPack.RocketPackReader r, int rank)
            {
                if (rank > 256)
                {
                    throw new System.FormatException();
                }

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

                System.ReadOnlyMemory <byte> p_sessionId          = System.ReadOnlyMemory <byte> .Empty;
                AuthenticationType           p_authenticationType = (AuthenticationType)0;

                KeyExchangeAlgorithm[]   p_keyExchangeAlgorithms   = System.Array.Empty <KeyExchangeAlgorithm>();
                KeyDerivationAlgorithm[] p_keyDerivationAlgorithms = System.Array.Empty <KeyDerivationAlgorithm>();
                CryptoAlgorithm[]        p_cryptoAlgorithms        = System.Array.Empty <CryptoAlgorithm>();
                HashAlgorithm[]          p_hashAlgorithms          = System.Array.Empty <HashAlgorithm>();

                for (; propertyCount > 0; propertyCount--)
                {
                    uint id = r.GetUInt32();
                    switch (id)
                    {
                    case 0:     // SessionId
                    {
                        p_sessionId = r.GetMemory(32);
                        break;
                    }

                    case 1:     // AuthenticationType
                    {
                        p_authenticationType = (AuthenticationType)r.GetUInt64();
                        break;
                    }

                    case 2:     // KeyExchangeAlgorithms
                    {
                        var length = r.GetUInt32();
                        p_keyExchangeAlgorithms = new KeyExchangeAlgorithm[length];
                        for (int i = 0; i < p_keyExchangeAlgorithms.Length; i++)
                        {
                            p_keyExchangeAlgorithms[i] = (KeyExchangeAlgorithm)r.GetUInt64();
                        }
                        break;
                    }

                    case 3:     // KeyDerivationAlgorithms
                    {
                        var length = r.GetUInt32();
                        p_keyDerivationAlgorithms = new KeyDerivationAlgorithm[length];
                        for (int i = 0; i < p_keyDerivationAlgorithms.Length; i++)
                        {
                            p_keyDerivationAlgorithms[i] = (KeyDerivationAlgorithm)r.GetUInt64();
                        }
                        break;
                    }

                    case 4:     // CryptoAlgorithms
                    {
                        var length = r.GetUInt32();
                        p_cryptoAlgorithms = new CryptoAlgorithm[length];
                        for (int i = 0; i < p_cryptoAlgorithms.Length; i++)
                        {
                            p_cryptoAlgorithms[i] = (CryptoAlgorithm)r.GetUInt64();
                        }
                        break;
                    }

                    case 5:     // HashAlgorithms
                    {
                        var length = r.GetUInt32();
                        p_hashAlgorithms = new HashAlgorithm[length];
                        for (int i = 0; i < p_hashAlgorithms.Length; i++)
                        {
                            p_hashAlgorithms[i] = (HashAlgorithm)r.GetUInt64();
                        }
                        break;
                    }
                    }
                }

                return(new ProfileMessage(p_sessionId, p_authenticationType, p_keyExchangeAlgorithms, p_keyDerivationAlgorithms, p_cryptoAlgorithms, p_hashAlgorithms));
            }