diff options
Diffstat (limited to 'lib/crypto/c_src/crypto_drv.c')
-rw-r--r-- | lib/crypto/c_src/crypto_drv.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/lib/crypto/c_src/crypto_drv.c b/lib/crypto/c_src/crypto_drv.c index 5b6d750dde..8c1356c4cf 100644 --- a/lib/crypto/c_src/crypto_drv.c +++ b/lib/crypto/c_src/crypto_drv.c @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 1999-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 1999-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -239,12 +239,15 @@ static ErlDrvEntry crypto_driver_entry = { #define DRV_BF_CBC_ENCRYPT 64 #define DRV_BF_CBC_DECRYPT 65 +#define DRV_ECB_DES_ENCRYPT 66 +#define DRV_ECB_DES_DECRYPT 67 + /* #define DRV_CBC_IDEA_ENCRYPT 34 */ /* #define DRV_CBC_IDEA_DECRYPT 35 */ /* Not DRV_DH_GENERATE_PARAMS DRV_DH_CHECK * Calc RSA_VERIFY_* and RSA_SIGN once */ -#define NUM_CRYPTO_FUNCS 46 +#define NUM_CRYPTO_FUNCS 48 #define MD5_CTX_LEN (sizeof(MD5_CTX)) #define MD5_LEN 16 @@ -538,6 +541,21 @@ static int crypto_control(ErlDrvData drv_data, unsigned int command, char *buf, (command == DRV_CBC_DES_ENCRYPT)); return dlen; + case DRV_ECB_DES_ENCRYPT: + case DRV_ECB_DES_DECRYPT: + /* buf = key[8] data */ + dlen = len - 8; + if (dlen != 8) + return -1; + des_key = (const_DES_cblock*) buf; + des_dbuf = (unsigned char *) (buf + 8); + bin = return_binary(rbuf,rlen,dlen); + if (bin==NULL) return -1; + DES_set_key(des_key, &schedule); + DES_ecb_encrypt((const_DES_cblock*) des_dbuf, (DES_cblock*) bin, &schedule, + (command == DRV_ECB_DES_ENCRYPT)); + return dlen; + case DRV_BF_ECB_ENCRYPT: case DRV_BF_ECB_DECRYPT: { |