diff options
author | Erlang/OTP <[email protected]> | 2010-04-01 06:11:22 +0000 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2010-04-01 06:11:22 +0000 |
commit | 39e0191d985078d6e9c12c504370425f1de5a6c5 (patch) | |
tree | b59410869e50ab4fd99fb0f7253405516d7d6cf1 /lib/crypto/c_src/crypto_drv.c | |
parent | 00ee51ffa60db202fa3cf845bd59e9e208251eb1 (diff) | |
parent | b869aef371836879f0dd1c306a90acb5f93f3ad0 (diff) | |
download | otp-39e0191d985078d6e9c12c504370425f1de5a6c5.tar.gz otp-39e0191d985078d6e9c12c504370425f1de5a6c5.tar.bz2 otp-39e0191d985078d6e9c12c504370425f1de5a6c5.zip |
Merge branch 'au/crypto' into dev
* au/crypto:
Add missing docs for crypto:md4/1
Add des_ecb_encrypt/2 and des_ecb_decrypt/2 to crypto module
OTP-8551 au/crypto
des_ecb_encrypt/2 and des_ecb_decrypt/2 has been added to the crypto
module. The crypto:md4/1 function has been documented.
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: { |