Hello, we are trying to use a Private Key given by a customer for signing strings.
However, we can not use it , because the object KeyPairGenerator seems just to function with it's own Generated keys.
Can anyone help us with this issue?
Here goes the code:
Dim private_key_string As String
private_key_string = "-----BEGIN RSA PRIVATE KEY-----"
private_key_string = private_key_string & "MIICXAIBAAKBgQDIDZu7wA9+NZWoMFGxDKf1agn84aIBt5L5k8NSAGBihOOUtbZW"
private_key_string = private_key_string & "ALVhiUkY4G0bAf/CncsqNACgluzqX9mSAcAX9zmkNwitFXvZ2Ck88ORm6EuIeSJn"
private_key_string = private_key_string & "9pjDOUWWX3qUJeIiQySsz3dDcKqRD/HTzDJ+al+hJiB21b3SYjJJPNXAsQIDAQAB"
private_key_string = private_key_string & "AoGAAmb/bsLArOBR2sIxyPGA9tZ+JjZDbsfYkPywRMTSY3x7CycfeGrrwq8WXKEd"
private_key_string = private_key_string & "Tky42IpyjSAwvbzyPWJHR5STzPBuDVNP4WxRDhW6x1n89QIHjbN7HpLqXo/A7Cjb"
private_key_string = private_key_string & "PqcJWgGCi5dUyflmSuoJZXybkZwvKsFXiWujqS4acDUXi50CQQDwnKraufo0Eyhe"
private_key_string = private_key_string & "Z9nYaK28+B/pzjCtU1LHvWBepp8J8gugoprWvkZ3a5zhm5klT8ldyDdGtU/Z/aSV"
private_key_string = private_key_string & "SUj3zKmbAkEA1NjoAIKBX3bgD8GvnRl8/ueAS2cQkNpD1t0jiKp7CRHng204Efil"
private_key_string = private_key_string & "FcjF4h5vWMyEVi23IA4youvTcprU1Yr5owJBAIYK4Wvku6yTF6QwOr5C4rcpi63W"
private_key_string = private_key_string & "/mswxiccKznPnT4PJ8cfjx8e9WbF/qn44wJURpwGVDUCATAyC6RXJV1XGQ0CQBFg"
private_key_string = private_key_string & "8HhyL2wDAcJnlxYlqZ4KeuAtNx4MpDNb9PXIrakM7DE/7q8Q9TG1JesTfxXqBPgg"
private_key_string = private_key_string & "XW5hmmLRDH+0AqK46S8CQAZi925W3MJEykfGvLuGN1bfuYeFUDRo1agFPauPKdCO"
private_key_string = private_key_string & "MJTPuYpApONr8Hea4uDl+61NN/Lg33Ft6E8rpPKfHtA="
private_key_string = private_key_string & "-----End RSA Private KEY-----"
' KeyparGenerator object
Dim myprivatekey As KeyPairGenerator
myprivatekey.Initialize("RSA",1024)
' Private key in bytes, to inject in KeyPairGenerator, since we want to use an external (string) private key
Dim private_key_byte() As Byte
private_key_byte = private_key_string.GetBytes("UTF8")
' prepare private key for Signature
myprivatekey.PrivateKeyFromBytes(private_key_byte)
Best Regards, Abílio.
However, we can not use it , because the object KeyPairGenerator seems just to function with it's own Generated keys.
Can anyone help us with this issue?
Here goes the code:
Dim private_key_string As String
private_key_string = "-----BEGIN RSA PRIVATE KEY-----"
private_key_string = private_key_string & "MIICXAIBAAKBgQDIDZu7wA9+NZWoMFGxDKf1agn84aIBt5L5k8NSAGBihOOUtbZW"
private_key_string = private_key_string & "ALVhiUkY4G0bAf/CncsqNACgluzqX9mSAcAX9zmkNwitFXvZ2Ck88ORm6EuIeSJn"
private_key_string = private_key_string & "9pjDOUWWX3qUJeIiQySsz3dDcKqRD/HTzDJ+al+hJiB21b3SYjJJPNXAsQIDAQAB"
private_key_string = private_key_string & "AoGAAmb/bsLArOBR2sIxyPGA9tZ+JjZDbsfYkPywRMTSY3x7CycfeGrrwq8WXKEd"
private_key_string = private_key_string & "Tky42IpyjSAwvbzyPWJHR5STzPBuDVNP4WxRDhW6x1n89QIHjbN7HpLqXo/A7Cjb"
private_key_string = private_key_string & "PqcJWgGCi5dUyflmSuoJZXybkZwvKsFXiWujqS4acDUXi50CQQDwnKraufo0Eyhe"
private_key_string = private_key_string & "Z9nYaK28+B/pzjCtU1LHvWBepp8J8gugoprWvkZ3a5zhm5klT8ldyDdGtU/Z/aSV"
private_key_string = private_key_string & "SUj3zKmbAkEA1NjoAIKBX3bgD8GvnRl8/ueAS2cQkNpD1t0jiKp7CRHng204Efil"
private_key_string = private_key_string & "FcjF4h5vWMyEVi23IA4youvTcprU1Yr5owJBAIYK4Wvku6yTF6QwOr5C4rcpi63W"
private_key_string = private_key_string & "/mswxiccKznPnT4PJ8cfjx8e9WbF/qn44wJURpwGVDUCATAyC6RXJV1XGQ0CQBFg"
private_key_string = private_key_string & "8HhyL2wDAcJnlxYlqZ4KeuAtNx4MpDNb9PXIrakM7DE/7q8Q9TG1JesTfxXqBPgg"
private_key_string = private_key_string & "XW5hmmLRDH+0AqK46S8CQAZi925W3MJEykfGvLuGN1bfuYeFUDRo1agFPauPKdCO"
private_key_string = private_key_string & "MJTPuYpApONr8Hea4uDl+61NN/Lg33Ft6E8rpPKfHtA="
private_key_string = private_key_string & "-----End RSA Private KEY-----"
' KeyparGenerator object
Dim myprivatekey As KeyPairGenerator
myprivatekey.Initialize("RSA",1024)
' Private key in bytes, to inject in KeyPairGenerator, since we want to use an external (string) private key
Dim private_key_byte() As Byte
private_key_byte = private_key_string.GetBytes("UTF8")
' prepare private key for Signature
myprivatekey.PrivateKeyFromBytes(private_key_byte)
Best Regards, Abílio.