0

Here I'm implementing digital signature using RSA. I read a plain text from a file and get MD5 i.e instance of a MessageDigest of the plain text and converting that plain text to BigInteger here this bigInteger should be signed.

MessageDigest m1 = MessageDigest.getInstance("MD5");

m1.update(bFile);

byte [] digest1 = m1.digest();

for(int i=0; i < digest1.length ; i++){
    System.out.println("b["+i+"]="+digest1[i]);
}

BigInteger bi = new BigInteger(digest1);

//here I dont know how to pass BigInteger to Signature function.

Could someone please help me with it.

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
Krishna
  • 939
  • 1
  • 11
  • 16
  • If you mean the [`Signature` class](http://docs.oracle.com/javase/7/docs/api/java/security/Signature.html), then you don't need to pass the data to be signed as a biginteger. This is done internally. Also, MD5 is not regarded as secure anymore. Don't use it. – Artjom B. Mar 15 '15 at 21:31
  • if not biginteger shall I pass it as bytearray only or is there anyother method to sign biginteger apart from Signature class – Krishna Mar 15 '15 at 21:50
  • [Sure](http://stackoverflow.com/questions/521101/using-sha1-and-rsa-with-java-security-signature-vs-messagedigest-and-cipher), but why do you want to sign a BigInteger specifically? Why this requirement? Are you trying to do a signature with textbook RSA for academic purposes? – Artjom B. Mar 15 '15 at 22:44
  • Yes for academic purpose.... – Krishna Mar 15 '15 at 22:46
  • 1
    So, you're asking someone to write an RSA signature implementation for you using BigInteger? – Artjom B. Mar 15 '15 at 23:09
  • I'm not asking someone to write for me... I'm implementing it but I was just eager to know if there is a method. (there is a difference) – Krishna Mar 15 '15 at 23:43

1 Answers1

0

You don't. You get the bytes out of the BigInteger and you pass those.

user207421
  • 305,947
  • 44
  • 307
  • 483