Exemple #1
0
        /// <summary>
        /// Retrieve a parameter set by its enumeration name
        /// </summary>
        ///
        /// <param name="ParamName">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 RNBWParameters FromName(RNBWParamNames ParamName)
        {
            switch (ParamName)
            {
            case RNBWParamNames.N33L5:
                return((RNBWParameters)RNBWN33L5.DeepCopy());

            case RNBWParamNames.N49L5:
                return((RNBWParameters)RNBWN49L5.DeepCopy());

            case RNBWParamNames.N54L5:
                return((RNBWParameters)RNBWN54L5.DeepCopy());

            case RNBWParamNames.N58L5:
                return((RNBWParameters)RNBWN58L5.DeepCopy());

            case RNBWParamNames.N60L5:
                return((RNBWParameters)RNBWN60L5.DeepCopy());

            case RNBWParamNames.N63L5:
                return((RNBWParameters)RNBWN63L5.DeepCopy());

            case RNBWParamNames.N66L5:
                return((RNBWParameters)RNBWN66L5.DeepCopy());

            default:
                throw new CryptoAsymmetricException("RNBWParamSets: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 RNBWParameters FromId(byte[] OId)
        {
            if (OId == null)
            {
                throw new CryptoAsymmetricException("RNBWParamSets:FromId", "OId can not be null!", new ArgumentException());
            }
            if (OId.Length != 4)
            {
                throw new CryptoAsymmetricException("RNBWParamSets:FromId", "OId must be 4 bytes in length!", new ArgumentException());
            }
            if (OId[0] != (byte)AsymmetricEngines.Rainbow)
            {
                throw new CryptoAsymmetricException("RNBWParamSets:FromId", "OId is not a valid Rainbow parameter id!", new ArgumentException());
            }

            if (OId[3] == 1)
            {
                return((RNBWParameters)RNBWN33L5.DeepCopy());
            }
            else if (OId[3] == 2)
            {
                return((RNBWParameters)RNBWN49L5.DeepCopy());
            }
            else if (OId[3] == 3)
            {
                return((RNBWParameters)RNBWN54L5.DeepCopy());
            }
            else if (OId[3] == 4)
            {
                return((RNBWParameters)RNBWN58L5.DeepCopy());
            }
            else if (OId[3] == 5)
            {
                return((RNBWParameters)RNBWN60L5.DeepCopy());
            }
            else if (OId[3] == 6)
            {
                return((RNBWParameters)RNBWN63L5.DeepCopy());
            }
            else if (OId[3] == 7)
            {
                return((RNBWParameters)RNBWN66L5.DeepCopy());
            }
            else
            {
                throw new CryptoAsymmetricException("RNBWParamSets:FromId", "OId does not identify a valid param set!", new ArgumentException());
            }
        }