Exemple #1
0
        /// <summary>
        /// Retrieve a parameter set by its enumeration name
        /// </summary>
        ///
        /// <param name="Name">The enumeration name</param>
        ///
        /// <returns>A populated parameter set</returns>
        ///
        /// <exception cref="CryptoAsymmetricException">Thrown if an invalid or unknown OId is specified</exception>
        public static MPKCParameters FromName(MPKCParamNames Name)
        {
            switch (Name)
            {
            case MPKCParamNames.FM11T40S256:
                return((MPKCParameters)MPKCFM11T40S256.DeepCopy());

            case MPKCParamNames.FM11T48S256:
                return((MPKCParameters)MPKCFM11T48S256.DeepCopy());

            case MPKCParamNames.FM12T31S256:
                return((MPKCParameters)MPKCFM12T31S256.DeepCopy());

            case MPKCParamNames.FM12T41S256:
                return((MPKCParameters)MPKCFM12T41S256.DeepCopy());

            case MPKCParamNames.FM12T48S256:
                return((MPKCParameters)MPKCFM12T48S256.DeepCopy());

            case MPKCParamNames.FM12T54K256:
                return((MPKCParameters)MPKCFM12T54K256.DeepCopy());

            case MPKCParamNames.FM12T67S256:
                return((MPKCParameters)MPKCFM12T67S256.DeepCopy());

            case MPKCParamNames.FM13T29S256:
                return((MPKCParameters)MPKCFM13T29S256.DeepCopy());

            case MPKCParamNames.FM13T44K256:
                return((MPKCParameters)MPKCFM13T44K256.DeepCopy());

            case MPKCParamNames.FM13T95S256:
                return((MPKCParameters)MPKCFM13T95S256.DeepCopy());

            case MPKCParamNames.FM14T24K256:
                return((MPKCParameters)MPKCFM14T24K256.DeepCopy());

            default:
                throw new CryptoAsymmetricException("MPKCParamSets:FromName", "The Parameter Name is not recognized!", new ArgumentException());
            }
        }
Exemple #2
0
        /// <summary>
        /// Retrieve a parameter set by its identity code
        /// </summary>
        ///
        /// <param name="OId">The 4 byte parameter set identity code</param>
        ///
        /// <returns>A populated parameter set</returns>
        ///
        /// <exception cref="CryptoAsymmetricException">Thrown if an invalid or unknown OId is specified</exception>
        public static MPKCParameters FromId(byte[] OId)
        {
            if (OId == null)
            {
                throw new CryptoAsymmetricException("MPKCParamSets:FromId", "OId can not be null!", new ArgumentException());
            }
            if (OId.Length != 4)
            {
                throw new CryptoAsymmetricException("MPKCParamSets:FromId", "OId must be 4 bytes in length!", new ArgumentException());
            }
            if (OId[0] != 1)
            {
                throw new CryptoAsymmetricException("MPKCParamSets:FromId", "OId is not a valid MPKC parameter id!", new ArgumentException());
            }

            if (OId[2] == 11)
            {
                if (OId[3] == 1)
                {
                    return((MPKCParameters)MPKCFM11T40S256.DeepCopy());
                }
                else if (OId[3] == 2)
                {
                    return((MPKCParameters)MPKCFM11T48S256.DeepCopy());
                }
            }
            else if (OId[2] == 12)
            {
                if (OId[3] == 1)
                {
                    return((MPKCParameters)MPKCFM12T31S256.DeepCopy());
                }
                else if (OId[3] == 2)
                {
                    return((MPKCParameters)MPKCFM12T41S256.DeepCopy());
                }
                else if (OId[3] == 3)
                {
                    return((MPKCParameters)MPKCFM12T48S256.DeepCopy());
                }
                else if (OId[3] == 4)
                {
                    return((MPKCParameters)MPKCFM12T54K256.DeepCopy());
                }
                else if (OId[3] == 5)
                {
                    return((MPKCParameters)MPKCFM12T67S256.DeepCopy());
                }
            }
            else if (OId[2] == 13)
            {
                if (OId[3] == 1)
                {
                    return((MPKCParameters)MPKCFM13T29S256.DeepCopy());
                }
                else if (OId[3] == 2)
                {
                    return((MPKCParameters)MPKCFM13T44K256.DeepCopy());
                }
                else if (OId[3] == 3)
                {
                    return((MPKCParameters)MPKCFM13T95S256.DeepCopy());
                }
            }
            else if (OId[2] == 14)
            {
                if (OId[3] == 1)
                {
                    return((MPKCParameters)MPKCFM14T24K256.DeepCopy());
                }
            }

            throw new CryptoAsymmetricException("MPKCParamSets:FromId", "OId does not identify a valid param set!", new ArgumentException());
        }