diff options
Diffstat (limited to 'src/pubkey/rsa/rsa.cpp')
-rw-r--r-- | src/pubkey/rsa/rsa.cpp | 70 |
1 files changed, 36 insertions, 34 deletions
diff --git a/src/pubkey/rsa/rsa.cpp b/src/pubkey/rsa/rsa.cpp index 7b74f3c57..83e6e1b17 100644 --- a/src/pubkey/rsa/rsa.cpp +++ b/src/pubkey/rsa/rsa.cpp @@ -1,7 +1,9 @@ -/************************************************* -* RSA Source File * -* (C) 1999-2008 Jack Lloyd * -*************************************************/ +/* +* RSA +* (C) 1999-2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ #include <botan/rsa.h> #include <botan/parsing.h> @@ -11,9 +13,9 @@ namespace Botan { -/************************************************* -* RSA_PublicKey Constructor * -*************************************************/ +/* +* RSA_PublicKey Constructor +*/ RSA_PublicKey::RSA_PublicKey(const BigInt& mod, const BigInt& exp) { n = mod; @@ -21,9 +23,9 @@ RSA_PublicKey::RSA_PublicKey(const BigInt& mod, const BigInt& exp) X509_load_hook(); } -/************************************************* -* RSA Public Operation * -*************************************************/ +/* +* RSA Public Operation +*/ BigInt RSA_PublicKey::public_op(const BigInt& i) const { if(i >= n) @@ -31,9 +33,9 @@ BigInt RSA_PublicKey::public_op(const BigInt& i) const return core.public_op(i); } -/************************************************* -* RSA Encryption Function * -*************************************************/ +/* +* RSA Encryption Function +*/ SecureVector<byte> RSA_PublicKey::encrypt(const byte in[], u32bit len, RandomNumberGenerator&) const { @@ -41,18 +43,18 @@ SecureVector<byte> RSA_PublicKey::encrypt(const byte in[], u32bit len, return BigInt::encode_1363(public_op(i), n.bytes()); } -/************************************************* -* RSA Verification Function * -*************************************************/ +/* +* RSA Verification Function +*/ SecureVector<byte> RSA_PublicKey::verify(const byte in[], u32bit len) const { BigInt i(in, len); return BigInt::encode(public_op(i)); } -/************************************************* -* Create a RSA private key * -*************************************************/ +/* +* Create a RSA private key +*/ RSA_PrivateKey::RSA_PrivateKey(RandomNumberGenerator& rng, u32bit bits, u32bit exp) { @@ -73,9 +75,9 @@ RSA_PrivateKey::RSA_PrivateKey(RandomNumberGenerator& rng, throw Self_Test_Failure(algo_name() + " private key generation failed"); } -/************************************************* -* RSA_PrivateKey Constructor * -*************************************************/ +/* +* RSA_PrivateKey Constructor +*/ RSA_PrivateKey::RSA_PrivateKey(RandomNumberGenerator& rng, const BigInt& prime1, const BigInt& prime2, const BigInt& exp, const BigInt& d_exp, @@ -93,9 +95,9 @@ RSA_PrivateKey::RSA_PrivateKey(RandomNumberGenerator& rng, PKCS8_load_hook(rng); } -/************************************************* -* RSA Private Operation * -*************************************************/ +/* +* RSA Private Operation +*/ BigInt RSA_PrivateKey::private_op(const byte in[], u32bit length) const { BigInt i(in, length); @@ -108,26 +110,26 @@ BigInt RSA_PrivateKey::private_op(const byte in[], u32bit length) const return r; } -/************************************************* -* RSA Decryption Operation * -*************************************************/ +/* +* RSA Decryption Operation +*/ SecureVector<byte> RSA_PrivateKey::decrypt(const byte in[], u32bit len) const { return BigInt::encode(private_op(in, len)); } -/************************************************* -* RSA Signature Operation * -*************************************************/ +/* +* RSA Signature Operation +*/ SecureVector<byte> RSA_PrivateKey::sign(const byte in[], u32bit len, RandomNumberGenerator&) const { return BigInt::encode_1363(private_op(in, len), n.bytes()); } -/************************************************* -* Check Private RSA Parameters * -*************************************************/ +/* +* Check Private RSA Parameters +*/ bool RSA_PrivateKey::check_key(RandomNumberGenerator& rng, bool strong) const { if(!IF_Scheme_PrivateKey::check_key(rng, strong)) |