aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/c_src/crypto_drv.c
diff options
context:
space:
mode:
authorAlexander Uvarov <[email protected]>2010-03-01 02:46:23 +0500
committerBjörn Gustavsson <[email protected]>2010-03-01 14:36:43 +0100
commit544ed5647d9a89fd2dbd62d56964fa37539bfa11 (patch)
treee704acc8166dae32b0a3d0591b22599187df86b7 /lib/crypto/c_src/crypto_drv.c
parentd7044099b8da0e5ea38b46764fd005698dc8c612 (diff)
downloadotp-544ed5647d9a89fd2dbd62d56964fa37539bfa11.tar.gz
otp-544ed5647d9a89fd2dbd62d56964fa37539bfa11.tar.bz2
otp-544ed5647d9a89fd2dbd62d56964fa37539bfa11.zip
Add des_ecb_encrypt/2 and des_ecb_decrypt/2 to crypto module
Diffstat (limited to 'lib/crypto/c_src/crypto_drv.c')
-rw-r--r--lib/crypto/c_src/crypto_drv.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/crypto/c_src/crypto_drv.c b/lib/crypto/c_src/crypto_drv.c
index 5b6d750dde..20b99a245b 100644
--- a/lib/crypto/c_src/crypto_drv.c
+++ b/lib/crypto/c_src/crypto_drv.c
@@ -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:
{