Deleted Added
sdiff udiff text old ( 302408 ) new ( 337982 )
full compact
1/* crypto/bn/bn_mod.c */
2/*
3 * Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de>
4 * for the OpenSSL project.
5 */
6/* ====================================================================
7 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *

--- 128 unchanged lines hidden (view full) ---

144{
145 if (!BN_add(r, a, b))
146 return 0;
147 return BN_nnmod(r, r, m, ctx);
148}
149
150/*
151 * BN_mod_add variant that may be used if both a and b are non-negative and
152 * less than m
153 */
154int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
155 const BIGNUM *m)
156{
157 if (!BN_uadd(r, a, b))
158 return 0;
159 if (BN_ucmp(r, m) >= 0)
160 return BN_usub(r, r, m);
161 return 1;
162}
163
164int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
165 BN_CTX *ctx)
166{
167 if (!BN_sub(r, a, b))
168 return 0;
169 return BN_nnmod(r, r, m, ctx);
170}
171

--- 145 unchanged lines hidden ---