ElGamal 签名未验证
ElGamal signature not verified
实施 ElGamal 加密
这是我到目前为止尝试过的方法,但没有成功
string lic = "abcdefghijklmnopqrstuvwxyz";
byte[] licenseKey = Encoding.UTF8.GetBytes(lic);
ElGamalKeyStruct key = new ElGamalKeyStruct();
key.P = new BigInteger(123567890);
key.G = new BigInteger(1234567890);
key.Y = new BigInteger(1234567890);
key.X = new BigInteger(0); //zero
byte[] signature = CreateSignature(licenseKey, key);
bool verified = VerifySignature(licenseKey, signature, key);
VerifySignature
总是returnsfalse
.
P 必须是素数。请参阅 here(即您使用的代码出自的电子书):
Create a random prime number, p. This number is the ElGamal "modulus." The number of bits required to represent p is the size of the public key, so that if p is represented using 1024 bits, then the key created by following the protocol is a 1024-bit key. We will select 607 as our example value.
如果您查看文本,就会找到生成 El Gamal 密钥的代码(CreateKeyPair()
方法)
这是我到目前为止尝试过的方法,但没有成功
string lic = "abcdefghijklmnopqrstuvwxyz";
byte[] licenseKey = Encoding.UTF8.GetBytes(lic);
ElGamalKeyStruct key = new ElGamalKeyStruct();
key.P = new BigInteger(123567890);
key.G = new BigInteger(1234567890);
key.Y = new BigInteger(1234567890);
key.X = new BigInteger(0); //zero
byte[] signature = CreateSignature(licenseKey, key);
bool verified = VerifySignature(licenseKey, signature, key);
VerifySignature
总是returnsfalse
.
P 必须是素数。请参阅 here(即您使用的代码出自的电子书):
Create a random prime number, p. This number is the ElGamal "modulus." The number of bits required to represent p is the size of the public key, so that if p is represented using 1024 bits, then the key created by following the protocol is a 1024-bit key. We will select 607 as our example value.
如果您查看文本,就会找到生成 El Gamal 密钥的代码(CreateKeyPair()
方法)