/// <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="NTRUException">Thrown if an invalid or unknown OId is used</exception> public static NTRUParameters FromName(NTRUParamNames Name) { switch (Name) { case NTRUParamNames.A2011439: return((NTRUParameters)APR2011439.Clone()); case NTRUParamNames.A2011743: return((NTRUParameters)APR2011743.Clone()); case NTRUParamNames.E1087EP2: return((NTRUParameters)EES1087EP2.Clone()); case NTRUParamNames.E1171EP1: return((NTRUParameters)EES1171EP1.Clone()); case NTRUParamNames.E1499EP1: return((NTRUParameters)EES1499EP1.Clone()); case NTRUParamNames.FA2011439: return((NTRUParameters)APR2011439FAST.Clone()); case NTRUParamNames.FA2011743: return((NTRUParameters)APR2011743FAST.Clone()); case NTRUParamNames.FE1087EP2: return((NTRUParameters)EES1087EP2FAST.Clone()); case NTRUParamNames.FE1171EP1: return((NTRUParameters)EES1171EP1FAST.Clone()); case NTRUParamNames.FE1499EP1: return((NTRUParameters)EES1499EP1FAST.Clone()); case NTRUParamNames.CX1861: return((NTRUParameters)CX1861SH512.Clone()); case NTRUParamNames.CX1931: return((NTRUParameters)CX1931SH512.Clone()); default: throw new NTRUException("NTRUParameters:FromName", "The enumeration name is unknown!", new ArgumentException()); } }
/// <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 used</exception> public static NTRUParameters FromName(NTRUParamNames ParamName) { switch (ParamName) { case NTRUParamNames.A2011439: return((NTRUParameters)APR2011439.DeepCopy()); case NTRUParamNames.A2011743: return((NTRUParameters)APR2011743.DeepCopy()); case NTRUParamNames.E1087EP2: return((NTRUParameters)EES1087EP2.DeepCopy()); case NTRUParamNames.E1171EP1: return((NTRUParameters)EES1171EP1.DeepCopy()); case NTRUParamNames.E1499EP1: return((NTRUParameters)EES1499EP1.DeepCopy()); case NTRUParamNames.FA2011439: return((NTRUParameters)APR2011439FAST.DeepCopy()); case NTRUParamNames.FA2011743: return((NTRUParameters)APR2011743FAST.DeepCopy()); case NTRUParamNames.FE1087EP2: return((NTRUParameters)EES1087EP2FAST.DeepCopy()); case NTRUParamNames.FE1171EP1: return((NTRUParameters)EES1171EP1FAST.DeepCopy()); case NTRUParamNames.FE1499EP1: return((NTRUParameters)EES1499EP1FAST.DeepCopy()); case NTRUParamNames.CX1861: return((NTRUParameters)CX1861SK512.DeepCopy()); case NTRUParamNames.CX1931: return((NTRUParameters)CX1931SK512.DeepCopy()); default: throw new CryptoAsymmetricException("NTRUParameters:FromName", "The enumeration name is unknown!", new ArgumentException()); } }
/// <summary> /// Retrieve a parameter set by its identity code /// </summary> /// /// <param name="OId">The 3 byte parameter set identity code</param> /// <param name="UseProduct">Use the product form parameters</param> /// /// <returns>A parameter set</returns> /// /// <exception cref="NTRUException">Thrown if an invalid or unknown OId is used</exception> public static NTRUParameters FromId(byte[] OId, bool UseProduct = true) { if (OId == null) { throw new NTRUException("NTRUParameters:FromId", "OId can not be null!", new ArgumentNullException()); } if (OId.Length != 3) { throw new NTRUException("NTRUParameters:FromId", "OId must be 3 bytes in length!", new ArgumentOutOfRangeException()); } if (OId[0] != 0) { throw new NTRUException("NTRUParameters:FromId", "OId is not a valid NTRU parameter id!", new ArgumentException()); } if (UseProduct) { if (OId[2] == 3) { return((NTRUParameters)EES1087EP2FAST.Clone()); } else if (OId[2] == 4) { return((NTRUParameters)EES1171EP1FAST.Clone()); } else if (OId[2] == 5) { return((NTRUParameters)EES1499EP1FAST.Clone()); } else if (OId[2] == 101) { return((NTRUParameters)APR2011439FAST.Clone()); } else if (OId[2] == 105) { return((NTRUParameters)APR2011743FAST.Clone()); } } else { if (OId[2] == 3) { return((NTRUParameters)EES1087EP2.Clone()); } else if (OId[2] == 4) { return((NTRUParameters)EES1171EP1.Clone()); } else if (OId[2] == 5) { return((NTRUParameters)EES1499EP1.Clone()); } else if (OId[2] == 101) { return((NTRUParameters)APR2011439.Clone()); } else if (OId[2] == 105) { return((NTRUParameters)APR2011743.Clone()); } else if (OId[2] == 7) { return((NTRUParameters)CX1861SH512.Clone()); } else if (OId[2] == 8) { return((NTRUParameters)CX1931SH512.Clone()); } } throw new NTRUException("NTRUParameters:FromId", "OId does not identify a valid param set!", new ArgumentException()); }
/// <summary> /// Retrieve a parameter set by its identity code /// </summary> /// /// <param name="OId">The 4 byte parameter set identity code</param> /// /// <returns>A parameter set</returns> /// /// <exception cref="CryptoAsymmetricException">Thrown if an invalid or unknown OId is used</exception> public static NTRUParameters FromId(byte[] OId) { if (OId == null) { throw new CryptoAsymmetricException("NTRUParameters:FromId", "OId can not be null!", new ArgumentNullException()); } if (OId.Length != 4) { throw new CryptoAsymmetricException("NTRUParameters:FromId", "OId must be 4 bytes in length!", new ArgumentOutOfRangeException()); } if (OId[0] != (byte)AsymmetricEngines.NTRU) { throw new CryptoAsymmetricException("NTRUParameters:FromId", "OId is not a valid NTRU parameter id!", new ArgumentException()); } if (OId[2] == 2) { if (OId[3] == 63) { return((NTRUParameters)EES1087EP2FAST.DeepCopy()); } else if (OId[3] == 64) { return((NTRUParameters)EES1171EP1FAST.DeepCopy()); } else if (OId[3] == 65) { return((NTRUParameters)EES1499EP1FAST.DeepCopy()); } else if (OId[3] == 101) { return((NTRUParameters)APR2011439FAST.DeepCopy()); } else if (OId[3] == 105) { return((NTRUParameters)APR2011743FAST.DeepCopy()); } } else if (OId[2] == 1) { if (OId[3] == 63) { return((NTRUParameters)EES1087EP2.DeepCopy()); } else if (OId[3] == 64) { return((NTRUParameters)EES1171EP1.DeepCopy()); } else if (OId[3] == 65) { return((NTRUParameters)EES1499EP1.DeepCopy()); } else if (OId[3] == 101) { return((NTRUParameters)APR2011439.DeepCopy()); } else if (OId[3] == 105) { return((NTRUParameters)APR2011743.DeepCopy()); } else if (OId[3] == 7) { return((NTRUParameters)CX1861SK512.DeepCopy()); } else if (OId[3] == 8) { return((NTRUParameters)CX1931SK512.DeepCopy()); } } throw new CryptoAsymmetricException("NTRUParameters:FromId", "OId does not identify a valid param set!", new ArgumentException()); }