From 30c143c1d037b1a01ce69edd1b533878a959e8ff Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sun, 9 Oct 2016 10:34:25 +0200 Subject: Bugfixes and debugging --- rsa.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'rsa.cpp') diff --git a/rsa.cpp b/rsa.cpp index 09ea1bc..94c9782 100644 --- a/rsa.cpp +++ b/rsa.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include "base64.h" @@ -26,7 +27,11 @@ namespace RSA{ pubkey.mod=privkey.mod=pq.first*pq.second; pubkey.exp=65537; Bigint x; - assert(egcd((pq.first-Bigint::one)*(pq.second-Bigint::one),pubkey.exp,x,privkey.exp)==1); + Bigint phi((pq.first-Bigint::one)*(pq.second-Bigint::one)); + assert(egcd(phi,pubkey.exp,x,privkey.exp)==1); + privkey.exp=privkey.exp.divmod(phi).second; + // cerr<<"pubkey = {"<