more, see below
On 9/25/2012 1:59 PM, Douglas E. Engert wrote:
On 9/25/2012 9:51 AM, redpath wrote:I have saved the private and public key of the ECDSA; Just sample code below. int len= i2o_ECPublicKey(eckey,NULL); unsigned char *buf=(unsigned char *)0; ret= i2o_ECPublicKey(eckey,( unsigned char **)&buf); if (!ret){ printf("Public key to octect string failed\n"); return 1; } printf("\ni2o public\n"); for (int i=0; i<len; i++) printf("%X ",buf[i]); printf("\n\n"); printf("started SHA1\n"); fp = fopen(args[1],"wb"); if (fp==NULL){ printf("Public file [%s] failed to create\n",args[1]); return 1; } fwrite(buf,1,len,fp); fclose(fp); And have used this public key to check signature simply by reading the file back as data to "pubdata" using this function. pubkey= o2i_ECPublicKey(&pubkey, (const unsigned char **)&pubdata, publen); But what is the best packaging for this Public key as in handing it out? I can simply provide this file but is there some packaging format generally used as Best Practices?
How about: http://www.ietf.org/rfc/rfc5480.txt So you could make this part of certificate, signed by a CA. If you want to just write the public key, then you could do something like: bp = BIO_new(BIO_s_file()); BIO_write_filename(bp, (char *)args[1]); evpkey = EVP_PKEY_new(); EVP_PKEY_assign_EC_KEY(evpkey, eckey); r = i2d_PUBKEY_bio(bp, evpkey); Then to view it you could use: openssl pkey -text_pub -noout -pubin -inform der -in key.file
-- Douglas E. Engert <[email protected]> Argonne National Laboratory 9700 South Cass Avenue Argonne, Illinois 60439 (630) 252-5444 ______________________________________________________________________ OpenSSL Project http://www.openssl.org Development Mailing List [email protected] Automated List Manager [email protected]
