174667Sjedgar/* 274667Sjedgar * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 374667Sjedgar * 474667Sjedgar * Licensed under the OpenSSL license (the "License"). You may not use 574667Sjedgar * this file except in compliance with the License. You can obtain a copy 674667Sjedgar * in the file LICENSE in the source distribution or at 774667Sjedgar * https://www.openssl.org/source/license.html 874667Sjedgar */ 974667Sjedgar 1074667Sjedgar#include <openssl/rc2.h> 1174667Sjedgar#include "rc2_local.h" 1274667Sjedgar#include <openssl/opensslv.h> 1374667Sjedgar 1474667Sjedgar/*- 1574667Sjedgar * RC2 as implemented frm a posting from 1674667Sjedgar * Newsgroups: sci.crypt 17184607Simp * Subject: Specification for Ron Rivests Cipher No.2 18184607Simp * Message-ID: <4fk39f$f70@net.auckland.ac.nz> 19184607Simp * Date: 11 Feb 1996 06:45:03 GMT 20184607Simp */ 21184607Simp 22184607Simpvoid RC2_ecb_encrypt(const unsigned char *in, unsigned char *out, RC2_KEY *ks, 23184607Simp int encrypt) 24184607Simp{ 2574667Sjedgar uint32_t l, d[2]; 2674667Sjedgar 2774667Sjedgar c2l(in, l); 2874667Sjedgar d[0] = l; 2974667Sjedgar c2l(in, l); 3074667Sjedgar d[1] = l; 3174667Sjedgar if (encrypt) 3274667Sjedgar RC2_encrypt(d, ks); 3374684Sru else 3474667Sjedgar RC2_decrypt(d, ks); 3575222Sru l = d[0]; 3674667Sjedgar l2c(l, out); 3784306Sru l = d[1]; 3884306Sru l2c(l, out); 3974667Sjedgar l = d[0] = d[1] = 0; 4074667Sjedgar} 4174667Sjedgar