public static bool IsCurveSupported(EccCurve curve) { #if __MonoCS__ return(false); #else return(RawEccKey.IsCurveSupported(curve)); #endif }
internal static bool IsCurveSupported(EccCurve curve) { int curveIndex = (int)curve; if (curveIndex < EcdsaCurveIDs.Length && EcdsaCurveIDs[curveIndex] != null) { return(true); } return(false); }
internal static uint MagicFromTpmAlgId(TpmAlgId algId, bool isEcdh, EccCurve curve, bool publicKey) { uint res = AlgInfo.FirstOrDefault(x => (x.Public == publicKey && x.KeyLength == GetKeyLength(curve) && x.Ecdh == isEcdh)).Magic; if (res == 0) { Globs.Throw("Unrecognized ECC parameter set"); } return(res); }
public bool CurveSupportsScheme(EccCurve curveId, TpmAlgId scheme) { if (!EccCurves.ContainsKey(curveId)) { return(false); } var curveParams = EccCurves[curveId]; return(curveParams.signScheme == TpmAlgId.Null || curveParams.signScheme == scheme); }
internal static int GetKeyLength(EccCurve curve) { switch (curve) { case EccCurve.TpmEccNistP256: return(256); case EccCurve.TpmEccNistP384: return(384); case EccCurve.TpmEccNistP521: return(521); } Globs.Throw <ArgumentException>("GetKeyLength(): Invalid ECC curve"); return(-1); }
///<param name = "the_symmetric">for a restricted decryption key, shall be set to a supported symmetric algorithm, key size. and mode. if the key is not a restricted decryption key, this field shall be set to TPM_ALG_NULL.</param> ///<param name = "the_scheme">If the sign attribute of the key is SET, then this shall be a valid signing scheme. NOTE If the sign parameter in curveID indicates a mandatory scheme, then this field shall have the same value. If the decrypt attribute of the key is SET, then this shall be a valid key exchange scheme or TPM_ALG_NULL. If the key is a Storage Key, then this field shall be TPM_ALG_NULL.(One of KeySchemeEcdh, KeySchemeEcmqv, SigSchemeRsassa, SigSchemeRsapss, SigSchemeEcdsa, SigSchemeEcdaa, SigSchemeSm2, SigSchemeEcschnorr, EncSchemeRsaes, EncSchemeOaep, SchemeHash, NullAsymScheme)</param> ///<param name = "the_curveID">ECC curve ID</param> ///<param name = "the_kdf">an optional key derivation scheme for generating a symmetric key from a Z value If the kdf parameter associated with curveID is not TPM_ALG_NULL then this is required to be NULL. NOTE There are currently no commands where this parameter has effect and, in the reference code, this field needs to be set to TPM_ALG_NULL.(One of SchemeMgf1, SchemeKdf1Sp80056a, SchemeKdf2, SchemeKdf1Sp800108, NullKdfScheme)</param> public EccParms( SymDefObject the_symmetric, IAsymSchemeUnion the_scheme, EccCurve the_curveID, IKdfSchemeUnion the_kdf ) { this.symmetric = the_symmetric; this.scheme = the_scheme; this.curveID = the_curveID; this.kdf = the_kdf; }
public EccParms() { symmetric = new SymDefObject(); curveID = new EccCurve(); }
public Tpm2EccParametersRequest() { curveID = new EccCurve(); }
public bool IsImplemented(EccCurve curve) { return(EccCurves.ContainsKey(curve)); }
public EccPoint EcEphemeral( EccCurve curveID, [SuppressMessage("Microsoft.Design", "CA1021")] out ushort counter ) { Tpm2EcEphemeralRequest inS = new Tpm2EcEphemeralRequest(); inS.curveID = curveID; TpmStructureBase outSBase; DispatchMethod(TpmCc.EcEphemeral, (TpmStructureBase) inS, typeof(Tpm2EcEphemeralResponse), out outSBase, 0, 0); Tpm2EcEphemeralResponse outS = (Tpm2EcEphemeralResponse) outSBase; counter = outS.counter; return outS.Q; }
public AlgorithmDetailEcc EccParameters( EccCurve curveID ) { Tpm2EccParametersRequest inS = new Tpm2EccParametersRequest(); inS.curveID = curveID; TpmStructureBase outSBase; DispatchMethod(TpmCc.EccParameters, (TpmStructureBase) inS, typeof(Tpm2EccParametersResponse), out outSBase, 0, 0); Tpm2EccParametersResponse outS = (Tpm2EccParametersResponse) outSBase; return outS.parameters; }
///<param name = "the_curveID">The curve for the computed ephemeral point</param> public Tpm2EcEphemeralRequest( EccCurve the_curveID ) { this.curveID = the_curveID; }
public Tpm2EcEphemeralRequest(Tpm2EcEphemeralRequest the_Tpm2EcEphemeralRequest) { if((Object) the_Tpm2EcEphemeralRequest == null ) throw new ArgumentException(Globs.GetResourceString("parmError")); curveID = the_Tpm2EcEphemeralRequest.curveID; }
public Tpm2EcEphemeralRequest() { curveID = new EccCurve(); }
///<param name = "the_curveID">parameter set selector</param> public Tpm2EccParametersRequest( EccCurve the_curveID ) { this.curveID = the_curveID; }
internal static byte[] GetKeyBlob(byte[] x, byte[] y, TpmAlgId alg, bool isEcdh, EccCurve curve) { var m = new Marshaller(); byte[] magic = BitConverter.GetBytes(MagicFromTpmAlgId(alg, isEcdh, curve, true)); m.Put(magic, ""); int keyBits = GetKeyLength(curve); int keySizeBytes = (keyBits + 7) / 8; if (x.Length != keySizeBytes || y.Length != keySizeBytes) { Globs.Throw <ArgumentException>("GetKeyBlob: Malformed ECC key"); return(new byte[0]); } var size = Globs.ReverseByteOrder(Globs.HostToNet(keySizeBytes)); m.Put(size, "len"); m.Put(x, "x"); m.Put(y, "y"); var res = m.GetBytes(); return(res); }
///<param name = "the_eccCurves">array of ECC curve identifiers</param> public EccCurveArray( EccCurve[] the_eccCurves ) { this.eccCurves = the_eccCurves; }
public static bool IsCurveSupported(EccCurve curve) { return(RawEccKey.IsCurveSupported(curve)); }
public AlgorithmDetailEcc() { curveID = new EccCurve(); }
///<param name = "the_curveID">identifier for the curve</param> ///<param name = "the_keySize">Size in bits of the key</param> ///<param name = "the_kdf">the default KDF and hash algorithm used in secret sharing operations(One of SchemeMgf1, SchemeKdf1Sp80056a, SchemeKdf2, SchemeKdf1Sp800108, NullKdfScheme)</param> ///<param name = "the_sign">If not TPM_ALG_NULL, this is the mandatory signature scheme that is required to be used with this curve.(One of KeySchemeEcdh, KeySchemeEcmqv, SigSchemeRsassa, SigSchemeRsapss, SigSchemeEcdsa, SigSchemeEcdaa, SigSchemeSm2, SigSchemeEcschnorr, EncSchemeRsaes, EncSchemeOaep, SchemeHash, NullAsymScheme)</param> ///<param name = "the_p">Fp (the modulus)</param> ///<param name = "the_a">coefficient of the linear term in the curve equation</param> ///<param name = "the_b">constant term for curve equation</param> ///<param name = "the_gX">x coordinate of base point G</param> ///<param name = "the_gY">y coordinate of base point G</param> ///<param name = "the_n">order of G</param> ///<param name = "the_h">cofactor (a size of zero indicates a cofactor of 1)</param> public AlgorithmDetailEcc( EccCurve the_curveID, ushort the_keySize, IKdfSchemeUnion the_kdf, IAsymSchemeUnion the_sign, byte[] the_p, byte[] the_a, byte[] the_b, byte[] the_gX, byte[] the_gY, byte[] the_n, byte[] the_h ) { this.curveID = the_curveID; this.keySize = the_keySize; this.kdf = the_kdf; this.sign = the_sign; this.p = the_p; this.a = the_a; this.b = the_b; this.gX = the_gX; this.gY = the_gY; this.n = the_n; this.h = the_h; }
public AlgorithmDetailEcc() { curveID = new EccCurve(); keySize = 0; p = null; a = null; b = null; gX = null; gY = null; n = null; h = null; }