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

            if (OId[3] == 1)
            {
                return((GMSSParameters)GMSSN2P10.DeepCopy());
            }
            else if (OId[3] == 2)
            {
                return((GMSSParameters)GMSSN2P20.DeepCopy());
            }
            else if (OId[3] == 3)
            {
                return((GMSSParameters)GMSSN2P40.DeepCopy());
            }
            else
            {
                throw new CryptoAsymmetricException("GMSSParamSets:FromId", "OId does not identify a valid param set!", new ArgumentException());
            }
        }
Esempio n. 2
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 GMSSParameters FromName(GMSSParamNames ParamName)
        {
            switch (ParamName)
            {
            case GMSSParamNames.N2P10:
                return((GMSSParameters)GMSSN2P10.DeepCopy());

            case GMSSParamNames.N2P20:
                return((GMSSParameters)GMSSN2P20.DeepCopy());

            case GMSSParamNames.N2P40:
                return((GMSSParameters)GMSSN2P40.DeepCopy());

            default:
                throw new CryptoAsymmetricException("GMSSParamSets:FromName", "The Parameter Name is not recognized!", new ArgumentException());
            }
        }