diff options
author | Miloslav Trmač <mitr@redhat.com> | 2010-07-22 17:35:05 +0200 |
---|---|---|
committer | Miloslav Trmač <mitr@redhat.com> | 2010-07-22 17:35:05 +0200 |
commit | ba1710ba3b123e790e0b604c689f9d5ae2b71971 (patch) | |
tree | 381bbae5f56b38e8d3a383f2046b26a1b3f7e1b6 /crypto/userspace/libtommath/bn_mp_reduce_2k_setup_l.c | |
parent | 9666790d5518a80bc9e2a7e21fcb6bf836c1548d (diff) | |
parent | 893a38ffe67459db005bd1c7f129c04508cd015d (diff) | |
download | kernel-crypto-ba1710ba3b123e790e0b604c689f9d5ae2b71971.tar.gz kernel-crypto-ba1710ba3b123e790e0b604c689f9d5ae2b71971.tar.xz kernel-crypto-ba1710ba3b123e790e0b604c689f9d5ae2b71971.zip |
Merge branch 'standalone-rename' into integrate-cryptodev
Conflicts:
.gitignore
Diffstat (limited to 'crypto/userspace/libtommath/bn_mp_reduce_2k_setup_l.c')
-rw-r--r-- | crypto/userspace/libtommath/bn_mp_reduce_2k_setup_l.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/crypto/userspace/libtommath/bn_mp_reduce_2k_setup_l.c b/crypto/userspace/libtommath/bn_mp_reduce_2k_setup_l.c new file mode 100644 index 00000000000..7cf002e8885 --- /dev/null +++ b/crypto/userspace/libtommath/bn_mp_reduce_2k_setup_l.c @@ -0,0 +1,44 @@ +#include <tommath.h> +#ifdef BN_MP_REDUCE_2K_SETUP_L_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + * + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org + */ + +/* determines the setup value */ +int mp_reduce_2k_setup_l(mp_int *a, mp_int *d) +{ + int res; + mp_int tmp; + + if ((res = mp_init(&tmp)) != MP_OKAY) { + return res; + } + + if ((res = mp_2expt(&tmp, mp_count_bits(a))) != MP_OKAY) { + goto ERR; + } + + if ((res = s_mp_sub(&tmp, a, d)) != MP_OKAY) { + goto ERR; + } + +ERR: + mp_clear(&tmp); + return res; +} +#endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_2k_setup_l.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/28 01:25:13 $ */ |