i have been given 256 byte modulus ('n'), 256 byte private exponent ('d') , 3 byte {1,0,1} public exponent ('e'). trying sign 32 bytes of data.
i have tried create new rsaparameters.
byte[] n = new byte[256]; //populated in code byte[] d = new byte[256]; //populated in code byte[] e = new byte[]{1,0,1}; byte[] junkdata = new byte[32]; //populated in code rsaparameters rsaparam = new rsaparameters(); rsaparam.modulus = n; rsaparam.exponent = e; rsaparam.d = d;
i create rsacrytoserviceprovider, import parameters it, , try sign data.
var csp = new rsacryptoserviceprovider(2048); csp.importparameters(rsaparam); csp.signdata(junkdata, new sha1cryptoserviceprovider());
the problem rsacryptoserviceprovider appears public only, , when try sign receive 'keyset not exist' cryptography exception.
do need p , q elements sign data, or doing wrong? help!
i'm surprised importparameters didn't throw (are using mono?).
rsacryptoserviceprovider (and of rsa implementations in .net framework , .net core) require populated rsaparameters structure private keys.
https://stackoverflow.com/a/42117655/6535399 gives answer in bit more detail.
Comments
Post a Comment