aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils/bit_ops.h
diff options
context:
space:
mode:
authorfstrenzke <[email protected]>2014-11-26 18:19:47 +0000
committerlloyd <[email protected]>2014-11-26 18:19:47 +0000
commit0ef9ee80a015c7c88902cd435cff9e54c7db5dc1 (patch)
tree8a2461cd384fee3da5e9469721e013380b450443 /src/lib/utils/bit_ops.h
parent2561eaf5c4794a97d2a2091b894d69e2c9f70c24 (diff)
Add an implementation of McEliece encryption based on HyMES
(https://www.rocq.inria.fr/secret/CBCrypto/index.php?pg=hymes). The original version is LGPL but cryptsource GmbH has secured permission to release it under a BSD license. Also includes the Overbeck CCA2 message encoding scheme.
Diffstat (limited to 'src/lib/utils/bit_ops.h')
-rw-r--r--src/lib/utils/bit_ops.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/lib/utils/bit_ops.h b/src/lib/utils/bit_ops.h
index 0072fde71..75a7584ad 100644
--- a/src/lib/utils/bit_ops.h
+++ b/src/lib/utils/bit_ops.h
@@ -1,6 +1,10 @@
/*
* Bit/Word Operations
* (C) 1999-2008 Jack Lloyd
+* (C) Copyright Projet SECRET, INRIA, Rocquencourt
+* (C) Bhaskar Biswas and Nicolas Sendrier
+* (C) 2014 cryptosource GmbH
+* (C) 2014 Falko Strenzke [email protected]
*
* Distributed under the terms of the Botan license
*/
@@ -98,6 +102,24 @@ inline size_t ctz(T n)
return 8*sizeof(T);
}
+template<typename T>
+size_t ceil_log2(T x)
+ {
+ if(x >> (sizeof(T)*8-1))
+ return sizeof(T)*8;
+
+ size_t result = 0;
+ T compare = 1;
+
+ while(compare < x)
+ {
+ compare <<= 1;
+ result++;
+ }
+
+ return result;
+ }
+
}
#endif