5ed079d15fdc53dd3d436ba0421131a27019749d
[openssl.git] / crypto / des / ecb_enc.c
1 /*
2  * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the OpenSSL license (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9
10 #include "des_locl.h"
11 #include <openssl/opensslv.h>
12 #include <openssl/bio.h>
13
14
15 const char *DES_options(void)
16 {
17     static int init = 1;
18     static char buf[12];
19
20     if (init) {
21         if (sizeof(DES_LONG) != sizeof(long))
22             OPENSSL_strlcpy(buf, "des(int)", sizeof(buf));
23         else
24             OPENSSL_strlcpy(buf, "des(long)", sizeof(buf));
25         init = 0;
26     }
27     return buf;
28 }
29
30 void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output,
31                      DES_key_schedule *ks, int enc)
32 {
33     register DES_LONG l;
34     DES_LONG ll[2];
35     const unsigned char *in = &(*input)[0];
36     unsigned char *out = &(*output)[0];
37
38     c2l(in, l);
39     ll[0] = l;
40     c2l(in, l);
41     ll[1] = l;
42     DES_encrypt1(ll, ks, enc);
43     l = ll[0];
44     l2c(l, out);
45     l = ll[1];
46     l2c(l, out);
47     l = ll[0] = ll[1] = 0;
48 }