release 0.92.3
[cntlm.git] / xcrypt.h
blob3822c76d69359796193689a6d155c1f022ce8a5b
1 /* des.c --- DES and Triple-DES encryption/decryption Algorithm
2 * Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007
3 * Free Software Foundation, Inc.
5 * This file is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published
7 * by the Free Software Foundation; either version 2, or (at your
8 * option) any later version.
10 * This file is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this file; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA.
20 * ----------------------------------------------------------------------
21 * Functions to compute MD4 message digest of files or memory blocks.
22 * according to the definition of MD4 in RFC 1320 from April 1992. Copyright
23 * (C) 1995,1996,1997,1999,2000,2001,2002,2003,2005,2006 Free Software
24 * Foundation, Inc.
26 * This program is free software; you can redistribute it and/or modify it
27 * under the terms of the GNU General Public License as published by the
28 * Free Software Foundation; either version 2, or (at your option) any
29 * later version.
31 * This program is distributed in the hope that it will be useful,
32 * but WITHOUT ANY WARRANTY; without even the implied warranty of
33 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 * GNU General Public License for more details.
36 * You should have received a copy of the GNU General Public License
37 * along with this program; if not, write to the Free Software Foundation,
38 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
41 #ifndef _XCRYPT_H
42 #define _XCRYPT_H
44 #include <stdint.h>
45 #include <stdbool.h>
46 #include <stddef.h>
47 #include <stdio.h>
49 #define MD5_DIGEST_SIZE 16
50 #define MD5_BLOCK_SIZE 64
51 #define IPAD 0x36
52 #define OPAD 0x5c
54 #define gl_des_ecb_encrypt(ctx, from, to) gl_des_ecb_crypt(ctx, from, to, 0)
55 #define gl_des_ecb_decrypt(ctx, from, to) gl_des_ecb_crypt(ctx, from, to, 1)
58 * Encryption/Decryption context of DES
60 typedef struct {
61 uint32_t encrypt_subkeys[32];
62 uint32_t decrypt_subkeys[32];
63 } gl_des_ctx;
65 /* Structures to save state of computation between the single steps. */
66 struct md4_ctx {
67 uint32_t A;
68 uint32_t B;
69 uint32_t C;
70 uint32_t D;
72 uint32_t total[2];
73 uint32_t buflen;
74 uint32_t buffer[32];
77 struct md5_ctx {
78 uint32_t A;
79 uint32_t B;
80 uint32_t C;
81 uint32_t D;
83 uint32_t total[2];
84 uint32_t buflen;
85 uint32_t buffer[32];
88 extern bool gl_des_is_weak_key(const char * key);
89 extern void gl_des_setkey(gl_des_ctx *ctx, const char * key);
90 extern bool gl_des_makekey(gl_des_ctx *ctx, const char * key, size_t keylen);
91 extern void gl_des_ecb_crypt(gl_des_ctx *ctx, const char * _from, char * _to, int mode);
93 extern void md4_process_block (const void *buffer, size_t len, struct md4_ctx *ctx);
94 extern void md4_init_ctx (struct md4_ctx *ctx);
95 extern void *md4_read_ctx (const struct md4_ctx *ctx, void *resbuf);
96 extern void *md4_finish_ctx (struct md4_ctx *ctx, void *resbuf);
97 extern void md4_process_bytes (const void *buffer, size_t len, struct md4_ctx *ctx);
98 extern int md4_stream(FILE * stream, void *resblock);
99 extern void *md4_buffer (const char *buffer, size_t len, void *resblock);
101 extern int hmac_md5 (const void *key, size_t keylen, const void *in, size_t inlen, void *resbuf);
103 extern void md5_init_ctx (struct md5_ctx *ctx);
104 extern void md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx);
105 extern void md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx);
106 extern void *md5_finish_ctx (struct md5_ctx *ctx, void *resbuf);
107 extern void *md5_read_ctx (const struct md5_ctx *ctx, void *resbuf);
108 extern int md5_stream (FILE *stream, void *resblock);
109 extern void *md5_buffer (const char *buffer, size_t len, void *resblock);
111 #endif /* _XCRYPT_H */