Beispiel #1
0
        /// <summary>
        /// Retrieve a DtmParameters by its enumeration name
        /// </summary>
        ///
        /// <param name="Name">The enumeration name</param>
        ///
        /// <returns>A populated DtmParameters parameter set</returns>
        ///
        /// <exception cref="CryptoAsymmetricException">Thrown if an invalid or unknown parameter name is used.</exception>
        public static DtmParameters FromName(DtmParamNames Name)
        {
            switch (Name)
            {
            // x1
            case DtmParamNames.X11RNS1R2:
                return((DtmParameters)DTMX11RNS1R2.DeepCopy());

            case DtmParamNames.X12RNR1R2:
                return((DtmParameters)DTMX12RNR1R2.DeepCopy());

            case DtmParamNames.X13RNS1S2:
                return((DtmParameters)DTMX13RNS1S2.DeepCopy());

            case DtmParamNames.X14RNT1T2:
                return((DtmParameters)DTMX14RNT1T2.DeepCopy());

            // x2
            case DtmParamNames.X21RNS1R2:
                return((DtmParameters)DTMX21RNS1R2.DeepCopy());

            case DtmParamNames.X22RNR1R2:
                return((DtmParameters)DTMX22RNR1R2.DeepCopy());

            case DtmParamNames.X23RNS1S2:
                return((DtmParameters)DTMX23RNS1S2.DeepCopy());

            case DtmParamNames.X24RNT1T2:
                return((DtmParameters)DTMX24RNT1T2.DeepCopy());

            // x3
            case DtmParamNames.X31RNS1R1:
                return((DtmParameters)DTMX31RNS1R1.DeepCopy());

            case DtmParamNames.X32RNR1R1:
                return((DtmParameters)DTMX32RNR1R1.DeepCopy());

            case DtmParamNames.X33RNS1S1:
                return((DtmParameters)DTMX33RNS1S1.DeepCopy());

            case DtmParamNames.X34RNT1T1:
                return((DtmParameters)DTMX34RNT1T1.DeepCopy());

            // x4
            case DtmParamNames.X41RNS1R1:
                return((DtmParameters)DTMX41RNS1R1.DeepCopy());

            case DtmParamNames.X42RNR1R1:
                return((DtmParameters)DTMX42RNR1R1.DeepCopy());

            case DtmParamNames.X43RNS1S1:
                return((DtmParameters)DTMX43RNS1S1.DeepCopy());

            case DtmParamNames.X44RNT1T1:
                return((DtmParameters)DTMX44RNT1T1.DeepCopy());

            default:
                throw new CryptoAsymmetricException("DtmParamSets:FromName", "The enumeration name is unknown!", new ArgumentException());
            }
        }
Beispiel #2
0
 /// <summary>
 /// Retrieve a DtmParameters by its identity code
 /// </summary>
 ///
 /// <param name="OId">The 16 byte parameter set identity code</param>
 ///
 /// <returns>A populated DtmParameters parameter set</returns>
 ///
 /// <exception cref="CryptoAsymmetricException">Thrown if an invalid or unknown OId is specified</exception>
 public static DtmParameters FromId(byte[] OId)
 {
     if (OId == null)
     {
         throw new CryptoAsymmetricException("DtmParamSets:FromId", "OId can not be null!", new ArgumentException());
     }
     if (OId.Length != 16)
     {
         throw new CryptoAsymmetricException("DtmParamSets:FromId", "OId must be at least 16 bytes in length!", new ArgumentException());
     }
     if (OId[0] != 1 && OId[0] != 2 && OId[0] != 3)
     {
         throw new CryptoAsymmetricException("DtmParamSets:FromId", "OId is not a valid DtmParameters parameter id!", new ArgumentException());
     }
     if (OId[4] != 1 && OId[4] != 2 && OId[4] != 3)
     {
         throw new CryptoAsymmetricException("DtmParamSets:FromId", "OId is not a valid DtmParameters parameter id!", new ArgumentException());
     }
     // x1
     if (Compare.IsEqual(OId, GetID(DtmParamNames.X11RNS1R2)))
     {
         return((DtmParameters)DTMX11RNS1R2.DeepCopy());
     }
     else if (Compare.IsEqual(OId, GetID(DtmParamNames.X12RNR1R2)))
     {
         return((DtmParameters)DTMX12RNR1R2.DeepCopy());
     }
     else if (Compare.IsEqual(OId, GetID(DtmParamNames.X13RNS1S2)))
     {
         return((DtmParameters)DTMX13RNS1S2.DeepCopy());
     }
     else if (Compare.IsEqual(OId, GetID(DtmParamNames.X14RNT1T2)))
     {
         return((DtmParameters)DTMX14RNT1T2.DeepCopy());
     }
     // x2
     else if (Compare.IsEqual(OId, GetID(DtmParamNames.X21RNS1R2)))
     {
         return((DtmParameters)DTMX21RNS1R2.DeepCopy());
     }
     else if (Compare.IsEqual(OId, GetID(DtmParamNames.X22RNR1R2)))
     {
         return((DtmParameters)DTMX22RNR1R2.DeepCopy());
     }
     else if (Compare.IsEqual(OId, GetID(DtmParamNames.X23RNS1S2)))
     {
         return((DtmParameters)DTMX23RNS1S2.DeepCopy());
     }
     else if (Compare.IsEqual(OId, GetID(DtmParamNames.X24RNT1T2)))
     {
         return((DtmParameters)DTMX24RNT1T2.DeepCopy());
     }
     // x3
     else if (Compare.IsEqual(OId, GetID(DtmParamNames.X31RNS1R1)))
     {
         return((DtmParameters)DTMX31RNS1R1.DeepCopy());
     }
     else if (Compare.IsEqual(OId, GetID(DtmParamNames.X32RNR1R1)))
     {
         return((DtmParameters)DTMX32RNR1R1.DeepCopy());
     }
     else if (Compare.IsEqual(OId, GetID(DtmParamNames.X33RNS1S1)))
     {
         return((DtmParameters)DTMX33RNS1S1.DeepCopy());
     }
     else if (Compare.IsEqual(OId, GetID(DtmParamNames.X34RNT1T1)))
     {
         return((DtmParameters)DTMX34RNT1T1.DeepCopy());
     }
     // x4
     else if (Compare.IsEqual(OId, GetID(DtmParamNames.X41RNS1R1)))
     {
         return((DtmParameters)DTMX41RNS1R1.DeepCopy());
     }
     else if (Compare.IsEqual(OId, GetID(DtmParamNames.X42RNR1R1)))
     {
         return((DtmParameters)DTMX42RNR1R1.DeepCopy());
     }
     else if (Compare.IsEqual(OId, GetID(DtmParamNames.X43RNS1S1)))
     {
         return((DtmParameters)DTMX43RNS1S1.DeepCopy());
     }
     else if (Compare.IsEqual(OId, GetID(DtmParamNames.X44RNT1T1)))
     {
         return((DtmParameters)DTMX44RNT1T1.DeepCopy());
     }
     else
     {
         throw new CryptoAsymmetricException("DtmParamSets:FromId", "OId does not identify a valid param set!", new ArgumentException());
     }
 }