summaryrefslogtreecommitdiffabout
path: root/lib/util.cc
Unidiff
Diffstat (limited to 'lib/util.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/util.cc10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/util.cc b/lib/util.cc
index d9abca7..94f6f53 100644
--- a/lib/util.cc
+++ b/lib/util.cc
@@ -86,9 +86,13 @@ namespace opkele {
86 } 86 }
87 87
88 string bignum_to_base64(const BIGNUM *bn) { 88 string bignum_to_base64(const BIGNUM *bn) {
89 vector<unsigned char> bin(BN_num_bytes(bn)); 89 vector<unsigned char> bin(BN_num_bytes(bn)+1);
90 int l = BN_bn2bin(bn,&(bin.front())); 90 unsigned char *binptr = &(bin.front())+1;
91 return encode_base64(&(bin.front()),l); 91 int l = BN_bn2bin(bn,binptr);
92 if(l && (*binptr)&0x80){
93 (*(--binptr)) = 0; ++l;
94 }
95 return encode_base64(binptr,l);
92 } 96 }
93 97
94 /* 98 /*