aboutsummaryrefslogtreecommitdiff
path: root/rsa.cpp
blob: 11bf0ebfca7521e7e2d7adc6bcaeb0df09397b35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#include <cassert>
#include "numalgo.h"
#include "rsa.h"

Bigint encrypt(const PublicKey &pubkey,Bigint msg){
	assert(msg>1&&msg<pubkey.mod);
	return expmod(msg,pubkey.exp,pubkey.mod);
}

Bigint decrypt(const PrivateKey &privkey,Bigint encr){
	return expmod(encr,privkey.pexp,privkey.pub.mod);
}