2 * Copyright (c) 2012 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
36 #include <corecrypto/ccmode.h>
37 #include <corecrypto/ccdes.h>
38 #include <corecrypto/ccn.h>
40 /* must be 32bit quantity */
41 #define DES_LONG u_int32_t
43 typedef unsigned char des_cblock
[8];
45 /* Unholy hack: this is currently the size for the only implementation of DES in corecrypto */
46 #define DES_ECB_CTX_MAX_SIZE (64*4)
47 #define DES3_ECB_CTX_MAX_SIZE (64*4*3)
51 ccecb_ctx_decl(DES_ECB_CTX_MAX_SIZE
, enc
);
52 ccecb_ctx_decl(DES_ECB_CTX_MAX_SIZE
, dec
);
53 } des_ecb_key_schedule
;
56 ccecb_ctx_decl(DES3_ECB_CTX_MAX_SIZE
, enc
);
57 ccecb_ctx_decl(DES3_ECB_CTX_MAX_SIZE
, dec
);
58 } des3_ecb_key_schedule
;
60 /* Only here for backward compatibility with smb kext */
61 typedef des_ecb_key_schedule des_key_schedule
[1];
62 #define des_set_key des_ecb_key_sched
68 /* Single DES ECB - 1 block */
69 int des_ecb_key_sched(des_cblock
*key
, des_ecb_key_schedule
*ks
);
70 void des_ecb_encrypt(des_cblock
* in
, des_cblock
*out
, des_ecb_key_schedule
*ks
, int encrypt
);
72 /* Triple DES ECB - 1 block */
73 int des3_ecb_key_sched(des_cblock
*key
, des3_ecb_key_schedule
*ks
);
74 void des3_ecb_encrypt(des_cblock
*block
, des_cblock
*, des3_ecb_key_schedule
*ks
, int encrypt
);
76 int des_is_weak_key(des_cblock
*key
);