/// <summary> /// /// </summary> /// <param name="pubkey"></param> /// <param name="privkey"></param> /// <param name="type"></param> /// <param name="mode"></param> public SM2(string pubkey, string privkey, KeyType type, SM2Mode mode = SM2Mode.C1C2C3) { var _pubkey = Helper.Decode(pubkey); var _privkey = Helper.Decode(privkey); if (type == KeyType.Pkcs8) { _pubkey = ((ECPublicKeyParameters)PublicKeyFactory.CreateKey(System.Convert.FromBase64String(pubkey))).Q.GetEncoded(); _privkey = ((ECPrivateKeyParameters)PrivateKeyFactory.CreateKey(System.Convert.FromBase64String(privkey))).D.ToByteArray(); } this.mode = mode; this.key = new KeyTool(_pubkey, _privkey); }
/// <summary> /// /// </summary> /// <param name="pubkey"></param> /// <param name="privkey"></param> /// <param name="mode"></param> public SM2(byte[] pubkey, byte[] privkey, SM2Mode mode = SM2Mode.C1C2C3) { this.mode = mode; this.key = new KeyTool(pubkey, privkey); }