LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-09-2011, 03:39 PM   #1
_john_i_
Member
 
Registered: Aug 2003
Location: Austin, TX
Distribution: Linux from Scratch
Posts: 52

Rep: Reputation: 15
Digital signatures in libgcrypt and in java.


I'm trying to verify digital signatures generated in libgcrypt in a java app using "MD5WithRSA" type signatures.

I think perhaps I am creating the signature incorrectly in libgcrypt, but I am not sure what to do to produce one that can be used by the java Signature class.

Here is how I am verifying in java:

Code:
Signature sig = Signature.getInstance("MD5WithRSA");
sig.initVerify(pubKey);
sig.update(data)
boolean result = sig.verify(signature);
The above works for signatures I created with the java Signature class, but not those I created in my C app with libgcrypt.

Here is my libgcrypt code for creating the signature:
Code:
char md5[16];

gcry_md_hash_buffer(GCRY_MD_MD5, md5, data, dataLen);

rc = gcry_sexp_build(&data_sexp, NULL, "(data(flags pkcs1)(hash md5 %b))", (size_t)16, md5)

rc = gcry_pk_sign(&signature, data_sexp, privKey);

I am able to verify the libgcrypt signatures with libgcrypt itself, so I am pretty sure I am just specifying some option wrong when creating the signature, or I am misunderstanding how to include the md5 using libgcrypt in a way that is compatible with the java Signature class.

Does anyone out there have experience with these libraries that might be able to help me figure out problem?

Thanks,

John

Last edited by _john_i_; 06-10-2011 at 12:23 PM. Reason: To mark as solved
 
Old 06-10-2011, 12:23 PM   #2
_john_i_
Member
 
Registered: Aug 2003
Location: Austin, TX
Distribution: Linux from Scratch
Posts: 52

Original Poster
Rep: Reputation: 15
[SOLVED] Digital signatures in libgcrypt and in java

I got it working, and I did have it coded correctly. The problem was of course human error

I was using the wrong variable as the signature, and not the one that matched the data. Doh!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Digital Signatures Creation possible with Linux?? Doomhammer Linux - Security 3 02-02-2009 11:52 AM
change setting for digital signatures Tiggs81972 Linux - Security 1 02-03-2007 02:00 AM
Generating Digital Signatures onyangoliech Linux - Security 2 11-23-2006 05:19 AM
Setting up digital signatures on Sendmail/Postfix SlackDaemon Linux - Security 2 06-30-2006 09:57 PM
openoffice digital signatures how to sailajabhandaru Linux - Software 0 11-23-2005 12:56 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration