Skip to content

Commit

Permalink
Revert pubkey test
Browse files Browse the repository at this point in the history
  • Loading branch information
etcimon committed Dec 11, 2023
1 parent 9b002c4 commit d9f0345
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
16 changes: 4 additions & 12 deletions examples/pubkey/source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ import std.stdio;
import memutils.unique;
import botan.libstate.lookup;
import botan.codec.hex : hexEncode;
import std.datetime.stopwatch;

void main() {
StopWatch s;
s.start();
for(int i = 0; i < 30; i++) {
Unique!AutoSeededRNG rng = new AutoSeededRNG;

const(ubyte)[] message = cast(const(ubyte)[])"Hello, this is a binary message!";
//writeln("Message: ", cast(string)message);
writeln("Message: ", cast(string)message);
auto privkey = RSAPrivateKey(*rng, 1024);

auto pubkey = RSAPublicKey(privkey);
Expand All @@ -23,12 +20,7 @@ void main() {
auto dec = scoped!PKDecryptorEME(privkey, "EME-PKCS1-v1_5");

Vector!ubyte encrypted_message = enc.encrypt(message.ptr, message.length, *rng);
//writeln("Encrypted: ", hexEncode(cast(const(ubyte)*)encrypted_message.ptr, encrypted_message.length));
writeln("Encrypted: ", hexEncode(cast(const(ubyte)*)encrypted_message.ptr, encrypted_message.length));
SecureVector!ubyte decrypted_message = dec.decrypt(encrypted_message);
//writeln("Decrypted: ", cast(string)decrypted_message[]);
}
s.stop();
writeln(s.peek().total!"msecs"());


writeln("Decrypted: ", cast(string)decrypted_message[]);
}
4 changes: 2 additions & 2 deletions source/botan/utils/donna128.d
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ public:
return donna128(this.lo() | y.lo(), this.hi() | y.hi());
}

@property ulong lo() const { return *cast(ulong*)&l;}
@property ulong hi() const { return *cast(ulong*)&h;}
@property ulong lo() const { return l;}
@property ulong hi() const { return h;}
private:
ulong l;
ulong h;
Expand Down

0 comments on commit d9f0345

Please sign in to comment.