> -----Original Message-----
> From: owner-openssl-us...@openssl.org 
> [mailto:owner-openssl-us...@openssl.org] On Behalf Of Bizhan 
> Gholikhamseh (bgholikh)
> Sent: Wednesday, July 08, 2009 5:38 PM
> To: openssl-users@openssl.org
> Subject: RE: Need help please: calculate SHA256.
> 
>  
> 
> > -----Original Message-----
> > From: owner-openssl-us...@openssl.org 
> > [mailto:owner-openssl-us...@openssl.org] On Behalf Of David Schwartz
> > Sent: Wednesday, July 08, 2009 3:05 PM
> > To: openssl-users@openssl.org
> > Subject: RE: Need help please: calculate SHA256.
> > 
> > 
> > Bizhan Gholikhamseh wrote:
> > 
> > > Hi all,
> > > I have an image that I need to calculate SHA256 has 
> digest of image 
> > > and encrypt the hash digest using my private key to 
> generate image 
> > > signature.
> > >
> > > Could someone please let me know how to use openssl to do this?
> > 
> > 1) Calculate the SHA256 hash.
> > 
> > 2) Sign it with the private key.
> > 
> > If you want a more specific answer, you're going to have to 
> ask a more 
> > specific question.
> 
> I have a text file, let us call it test.tx, which I need to 
> send it through a secure mechanism to a remote site.
> I have already created a pair of public and private rsa key 
> using openssl.
> I want to use openssl to generate a sha256 hash digest of the 
> text file, i.e. test.tx --> test.hash.
> And encrypt the hash file with my private key i.e. test.hash 
> --> test.sign.
> I believe this process is called signing the image (I am very 
> new in this area).
> 
> Any help greatly appreciated,

Here are a series of openssl commands you can use to encrypt and
generate a hash.  I used AES-256 and SHA-384 in the example given.

1. echo "Hello" >foobar.txt

2. Encrypt: openssl aes256 -salt -in foobar.txt -out scrambled.txt

3. Decrypt: openssl aes256 -d -in scrambled.txt

4. Hash of Plaintext: openssl dgst -sha384 foobar.txt
 -
1d283e09aa7e597f2c0505c13f7c09eb4d4cd198fb7b144eeea2824cc59a046d9363b3f0
38abf7aa6bde7f8adaf561a4

5. Hash of Ciphertext: openssl dgst -sha384 scrambled.txt
 -
27e251831d2fb862ca092e4f0dacadb5fe3954240e377c387e4e903a25a492ed2129106b
993fb94fa709f7ca942e433f

6. ls -ltr
foobar.txt - 6 bytes
scrambed.txt - 32 bytes

> 
> --B
> 
> 
> > 
> > Are you trying to write a program? Are you trying to use 
> the 'openssl'
> > application? Is there some specific image signing format 
> you're trying 
> > to use? Who or what is supposed to be able to verify this signature 
> > and using what format?
> > 
> > Your question is like "how can I use steel to build a 
> bridge". You get 
> > the steel and you form it into a bridge with tools.
> > 
> > DS
> > 
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to