diff options
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | bigint.cpp | 2 | ||||
-rw-r--r-- | bigint.h | 8 | ||||
-rw-r--r-- | main.cpp | 3 | ||||
-rw-r--r-- | rng.cpp | 6 |
5 files changed, 19 insertions, 8 deletions
@@ -1,10 +1,14 @@ CXX = g++ -CXXFLAGS = -Wall -Wextra -std=c++11 -fwrapv +CXXFLAGS = -Wall -Wextra -std=c++0x -fwrapv +LDFLAGS = ifneq ($(DEBUG),) CXXFLAGS += -g else CXXFLAGS += -O2 endif +ifeq ($(shell uname),Linux) + LDFLAGS += -lbsd +endif BIN = main .PHONY: all clean remake @@ -18,7 +22,7 @@ remake: clean all $(BIN): $(patsubst %.cpp,%.o,$(wildcard *.cpp)) - $(CXX) -o $@ $^ + $(CXX) -o $@ $^ $(LDFLAGS) %.o: %.cpp $(wildcard *.h) $(CXX) $(CXXFLAGS) -c -o $@ $< @@ -617,7 +617,7 @@ std::ostream& operator<<(std::ostream &os,Bigint b){ return os; #else if(b==0)return os<<'0'; - Bigint div(1000000000000000000LL); + Bigint div((int64_t)1000000000000000000LL); vector<Bigint::longdigit_t> outbuf; while(b!=0){ pair<Bigint,Bigint> dm=b.divmod(div); @@ -8,10 +8,10 @@ class Bigint{ public: - using digit_t=uint32_t; - using sdigit_t=int32_t; - using longdigit_t=uint64_t; - using slongdigit_t=int64_t; + typedef uint32_t digit_t; + typedef int32_t sdigit_t; + typedef uint64_t longdigit_t; + typedef int64_t slongdigit_t; static const int digit_bits=8*sizeof(digit_t); private: @@ -2,6 +2,7 @@ #include <fstream> #include <sstream> #include <stdexcept> +#include <algorithm> #include <cstdlib> #include <cctype> #include <ctime> @@ -133,7 +134,7 @@ void testisqrt(int argc,char **argv){ void performrsa(){ RSA::PrivateKey privkey; Bigint p(1000000007),q(3000000019U); - privkey.pub.mod=3000000040000000133LL; + privkey.pub.mod=(int64_t)3000000040000000133LL; privkey.pub.exp=65537; { Bigint x; @@ -4,6 +4,12 @@ #include <cassert> #include "rng.h" +#ifdef __APPLE__ +#include <cstdlib> +#else +#include <bsd/stdlib.h> +#endif + using namespace std; |