[openssl-users] Java Snippet output is not equal to command line openssl command output , Why ?

timmy pony tim.fortinbras at gmail.com
Wed Aug 1 16:51:03 UTC 2018


Hi Vicktor - I put a '\n' at end of java snippet

Both are now equal

Thank you for your help.

On Wed, Aug 1, 2018 at 5:47 PM timmy pony <tim.fortinbras at gmail.com> wrote:

> Hi Vicktor,  Speed read the previous mail.
>
>
>
> On Wed, Aug 1, 2018 at 4:28 PM Viktor Dukhovni <openssl-users at dukhovni.org>
> wrote:
>
>> On Wed, Aug 01, 2018 at 09:24:38AM +0100, timmy pony wrote:
>>
>> > I have tried this
>> >
>> > openssl dgst -sha256 -sign my_private.key -out /tmp/sign.sha256
>> codeTosign.txt
>>
>> This produces raw binary output, no base64 encoding.  What is the
>> content of the file "codeToSign.txt"?  Post the output of:
>>
>>     od -tx1 < /tmp/codeToSign.txt
>>
>
>  od -tx1 < codeToSign.txt
>
> 0000000    73  61  6d  70  6c  65  20  69  6e  70  75  74  0a
>
> 0000015
>
>
>>
>> > public class SHA256RSA {
>> >
>> >     public static void main(String[] args) throws Exception {
>> >         String input = "sample input";
>>
>> This input has no newline ending, perhaps the disk file does.
>>
>> >         // Not a real private key! Replace with your private key!
>> >         String strPk = "-----BEGIN PRIVATE
>> KEY-----\nMIIEvwIBADANBgkqhkiG9"
>> >                 + "w0BAQEFAASCBKkwggSlAgEAAoIBAQDJUGqaRB11KjxQ\nKHDeG"
>> >                 +
>> "........................................................"
>> >                 + "Ldt0hAPNl4QKYWCfJm\nNf7Afqaa/RZq0+y/36v83NGENQ==\n"
>> >                 + "-----END PRIVATE KEY-----\n";
>>
>> I sure hope your production code will *NOT* have the private key
>> embedded in the executable.
>>
>> >         String base64Signature = signSHA256RSA(input,strPk);
>> >         System.out.println("Signature="+base64Signature);
>>
>> This outputs a signature encoded in base64.
>>
>> --
>>         Viktor.
>> --
>> openssl-users mailing list
>> To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mta.openssl.org/pipermail/openssl-users/attachments/20180801/8d6edd6e/attachment.html>


More information about the openssl-users mailing list