M
Mattia Saccotelli
Hi
I would like to encrypt data using AES (Rijndael) algorithm, providing
as the key the key from a given certificate. Just for testing I'm using
the public key..
Shouldn't I use the private key instead of the public one?
Is there a way to get it or to use such algorithm with a specified
private key from a certificate (which may eventually be on a regular file)?
--
About the public key I did the following to get an appropriate key length:
private byte[] getKey() {
X509Certificate cer =
X509Certificate.CreateFromCertFile(@"c:\tmp\certificates\mattia.cer");
byte[] certKey = cer.GetPublicKey();
byte[] theKey = new byte[keySize / 8];
for (int i = 0; i < (keySize / 8) && i < certKey.Length; i++) {
theKey = certKey;
}
return theKey;
}
BTW I think it's not the right way to solve the problem, I can't simply
truncate the key to the needed length.
I would like to encrypt data using AES (Rijndael) algorithm, providing
as the key the key from a given certificate. Just for testing I'm using
the public key..
Shouldn't I use the private key instead of the public one?
Is there a way to get it or to use such algorithm with a specified
private key from a certificate (which may eventually be on a regular file)?
--
About the public key I did the following to get an appropriate key length:
private byte[] getKey() {
X509Certificate cer =
X509Certificate.CreateFromCertFile(@"c:\tmp\certificates\mattia.cer");
byte[] certKey = cer.GetPublicKey();
byte[] theKey = new byte[keySize / 8];
for (int i = 0; i < (keySize / 8) && i < certKey.Length; i++) {
theKey = certKey;
}
return theKey;
}
BTW I think it's not the right way to solve the problem, I can't simply
truncate the key to the needed length.