c# - RSA private key encryption -
is there way perform private key encryption in c#?
i know standard rsacryptoserviceprovider
in system.security.cryptography
, these classes provide public key encryption , private key decryption. also, provide digital signature functionality, uses internally private key encryption, there not publicly accessible functions perform private key encryption , public key decryption.
i've found this article on codeproject, start point performing kind of encryption, however, looking ready-to-use code, code in article can hardly encrypt arbitrary-long byte arrays containing random values (that means values, including zeroes).
do know components (preferably free) perform private key encryption?
use .net 3.5
.
note: i know considered bad way of using asymmetric encryption (encrypting using private key , decrypting using public key), need use way.
additional explanation
consider have
var bytes = new byte[30] { /* ... */ };
and want use 2048bit rsa
ensure no 1 have changed in array.
normally, use digital signature (ie. ripemd160
), attach original bytes , send on receiver.
so, have 30 bytes of original data, , additional 256 bytes of digital signature (because 2048bit rsa
), overall of 286 bytes. hovewer, 160 bits of 256 bytes hash, there 1888 bits (236 bytes) unused.
so, idea this:
take 30 bytes of original data, attach hash (20 bytes), , encrypt these 50 bytes. 256 bytes long message, shorter 286 bytes, because "you able push actual data inside digital signature".
ecdsa resources
msdn
eggheadcafe.com
c-plusplus.de
msdn blog
wiki
dsa resources
codeproject
msdn 1
msdn 2
msdn 3
final solution
if interested how i've solved problem, i'm going use 1024bit dsa
, sha1
, supported on many different versions of windows (windows 2000
, newer), security enough (i'm not signing orders, need ensure child can't crack signature on iphone (:-d)), , signature size 40 bytes long.
what trying design known "signature scheme message recovery".
designing new signature scheme hard. designing new signature scheme message recovery harder. don't know details design, there chance susceptible chosen message attack.
one proposal signature schemes message recovery rsa pss-r. unfortunately, proposal covered patent.
the ieee p1363 standarization group, once discussed addition of signature schemes message recovery. however, i'm not sure current state of effort, might worth checking out.
Comments
Post a Comment