1 /* ppp-crypto.h - Generic API for access to crypto/digest functions.
3 * Copyright (c) 2022 Eivind Næss. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
17 * 3. The name(s) of the authors of this software must not be used to
18 * endorse or promote products derived from this software without
19 * prior written permission.
21 * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
22 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
23 * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
24 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
25 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
26 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
27 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
33 #ifndef MD5_DIGEST_LENGTH
34 #define MD5_DIGEST_LENGTH 16
37 #ifndef MD4_DIGEST_LENGTH
38 #define MD4_DIGEST_LENGTH 16
41 #ifndef SHA_DIGEST_LENGTH
42 #define SHA_DIGEST_LENGTH 20
48 typedef struct _PPP_MD_CTX PPP_MD_CTX;
49 typedef struct _PPP_MD PPP_MD;
52 PPP_MD_CTX *PPP_MD_CTX_new();
53 void PPP_MD_CTX_free(PPP_MD_CTX*);
56 const PPP_MD *PPP_md4(void);
57 const PPP_MD *PPP_md5(void);
58 const PPP_MD *PPP_sha1(void);
61 int PPP_DigestInit(PPP_MD_CTX *ctx,
63 int PPP_DigestUpdate(PPP_MD_CTX *ctx,
64 const void *data, size_t cnt);
65 int PPP_DigestFinal(PPP_MD_CTX *ctx,
66 unsigned char *out, unsigned int *outlen);
69 struct _PPP_CIPHER_CTX;
72 typedef struct _PPP_CIPHER_CTX PPP_CIPHER_CTX;
73 typedef struct _PPP_CIPHER PPP_CIPHER;
76 PPP_CIPHER_CTX *PPP_CIPHER_CTX_new(void);
77 void PPP_CIPHER_CTX_free(PPP_CIPHER_CTX *ctx);
79 const PPP_CIPHER *PPP_des_ecb(void);
81 void PPP_CIPHER_CTX_set_cipher_data(PPP_CIPHER_CTX *ctx,
82 const unsigned char *key);
84 int PPP_CipherInit(PPP_CIPHER_CTX *ctx,
85 const PPP_CIPHER *cipher,
86 const unsigned char *key, const unsigned char *iv,
89 int PPP_CipherUpdate(PPP_CIPHER_CTX *ctx,
90 unsigned char *out, int *outl,
91 const unsigned char *in, int inl);
93 int PPP_CipherFinal(PPP_CIPHER_CTX *ctx,
94 unsigned char *out, int *outl);
96 int PPP_crypto_init();
97 int PPP_crypto_deinit();