]> git.ozlabs.org Git - ppp.git/blob - pppd/ppp-crypto.h
b1688b86d26bf38dfef3843464efe3e87cb73106
[ppp.git] / pppd / ppp-crypto.h
1 /* ppp-crypto.h - Generic API for access to crypto/digest functions.
2  *
3  * Copyright (c) 2022 Eivind Næss. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
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
15  *    distribution.
16  *
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.
20  *
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.
28  */
29
30 #ifndef PPP_CRYPTO_H
31 #define PPP_CRYPTO_H
32
33
34 #ifndef SHA1_SIGNATURE_SIZE
35 #ifdef SHA_DIGESTSIZE
36 #define SHA1_SIGNATURE_SIZE SHA_DIGESTSIZE
37 #else
38 #define SHA1_SIGNATURE_SIZE 20
39 #endif
40 #endif
41
42
43 struct _PPP_MD_CTX;
44 struct _PPP_MD;
45
46 typedef struct _PPP_MD_CTX PPP_MD_CTX;
47 typedef struct _PPP_MD PPP_MD;
48
49
50 PPP_MD_CTX *PPP_MD_CTX_new();
51 void PPP_MD_CTX_free(PPP_MD_CTX*);
52
53
54 const PPP_MD *PPP_md4(void);
55 const PPP_MD *PPP_md5(void);
56 const PPP_MD *PPP_sha1(void);
57
58
59 int PPP_DigestInit(PPP_MD_CTX *ctx,
60         const PPP_MD *type);
61 int PPP_DigestUpdate(PPP_MD_CTX *ctx,
62         const void *data, size_t cnt);
63 int PPP_DigestFinal(PPP_MD_CTX *ctx,
64         unsigned char *out, unsigned int *outlen);
65
66
67 struct _PPP_CIPHER_CTX;
68 struct _PPP_CIPHER;
69
70 typedef struct _PPP_CIPHER_CTX PPP_CIPHER_CTX;
71 typedef struct _PPP_CIPHER PPP_CIPHER;
72
73
74 PPP_CIPHER_CTX *PPP_CIPHER_CTX_new(void);
75 void PPP_CIPHER_CTX_free(PPP_CIPHER_CTX *ctx);
76
77 const PPP_CIPHER *PPP_des_ecb(void);
78
79 void PPP_CIPHER_CTX_set_cipher_data(PPP_CIPHER_CTX *ctx,
80         const unsigned char *key);
81
82 int PPP_CipherInit(PPP_CIPHER_CTX *ctx,
83         const PPP_CIPHER *cipher,
84         const unsigned char *key, const unsigned char *iv,
85         int encr);
86
87 int PPP_CipherUpdate(PPP_CIPHER_CTX *ctx,
88         unsigned char *out, int *outl,
89         const unsigned char *in, int inl);
90
91 int PPP_CipherFinal(PPP_CIPHER_CTX *ctx,
92         unsigned char *out, int *outl);
93
94 int PPP_crypto_init();
95 int PPP_crypto_deinit();
96
97 #endif