| OLD | NEW |
| 1 /* crypto/rc5/rc5_skey.c */ | 1 /* crypto/rc5/rc5_skey.c */ |
| 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * This package is an SSL implementation written | 5 * This package is an SSL implementation written |
| 6 * by Eric Young (eay@cryptsoft.com). | 6 * by Eric Young (eay@cryptsoft.com). |
| 7 * The implementation was written so as to conform with Netscapes SSL. | 7 * The implementation was written so as to conform with Netscapes SSL. |
| 8 * | 8 * |
| 9 * This library is free for commercial and non-commercial use as long as | 9 * This library is free for commercial and non-commercial use as long as |
| 10 * the following conditions are aheared to. The following conditions | 10 * the following conditions are aheared to. The following conditions |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 51 * SUCH DAMAGE. | 51 * SUCH DAMAGE. |
| 52 * | 52 * |
| 53 * The licence and distribution terms for any publically available version or | 53 * The licence and distribution terms for any publically available version or |
| 54 * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 * derivative of this code cannot be changed. i.e. this code cannot simply be |
| 55 * copied and put under another distribution licence | 55 * copied and put under another distribution licence |
| 56 * [including the GNU Public Licence.] | 56 * [including the GNU Public Licence.] |
| 57 */ | 57 */ |
| 58 | 58 |
| 59 #include <openssl/crypto.h> | |
| 60 #include <openssl/rc5.h> | 59 #include <openssl/rc5.h> |
| 61 #ifdef OPENSSL_FIPS | |
| 62 #include <openssl/fips.h> | |
| 63 #endif | |
| 64 | |
| 65 #include "rc5_locl.h" | 60 #include "rc5_locl.h" |
| 66 | 61 |
| 67 #ifdef OPENSSL_FIPS | |
| 68 void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data, | 62 void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data, |
| 69 int rounds) | 63 int rounds) |
| 70 { | 64 { |
| 71 if (FIPS_mode()) | |
| 72 FIPS_BAD_ABORT(RC5) | |
| 73 private_RC5_32_set_key(key, len, data, rounds); | |
| 74 } | |
| 75 void private_RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data, | |
| 76 int rounds) | |
| 77 #else | |
| 78 void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data, | |
| 79 int rounds) | |
| 80 #endif | |
| 81 { | |
| 82 RC5_32_INT L[64],l,ll,A,B,*S,k; | 65 RC5_32_INT L[64],l,ll,A,B,*S,k; |
| 83 int i,j,m,c,t,ii,jj; | 66 int i,j,m,c,t,ii,jj; |
| 84 | 67 |
| 85 if ( (rounds != RC5_16_ROUNDS) && | 68 if ( (rounds != RC5_16_ROUNDS) && |
| 86 (rounds != RC5_12_ROUNDS) && | 69 (rounds != RC5_12_ROUNDS) && |
| 87 (rounds != RC5_8_ROUNDS)) | 70 (rounds != RC5_8_ROUNDS)) |
| 88 rounds=RC5_16_ROUNDS; | 71 rounds=RC5_16_ROUNDS; |
| 89 | 72 |
| 90 key->rounds=rounds; | 73 key->rounds=rounds; |
| 91 S= &(key->data[0]); | 74 S= &(key->data[0]); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 121 k=(S[ii]+A+B)&RC5_32_MASK; | 104 k=(S[ii]+A+B)&RC5_32_MASK; |
| 122 A=S[ii]=ROTATE_l32(k,3); | 105 A=S[ii]=ROTATE_l32(k,3); |
| 123 m=(int)(A+B); | 106 m=(int)(A+B); |
| 124 k=(L[jj]+A+B)&RC5_32_MASK; | 107 k=(L[jj]+A+B)&RC5_32_MASK; |
| 125 B=L[jj]=ROTATE_l32(k,m); | 108 B=L[jj]=ROTATE_l32(k,m); |
| 126 if (++ii >= t) ii=0; | 109 if (++ii >= t) ii=0; |
| 127 if (++jj >= c) jj=0; | 110 if (++jj >= c) jj=0; |
| 128 } | 111 } |
| 129 } | 112 } |
| 130 | 113 |
| OLD | NEW |