1 /* ppp-crypo-priv.h - Crypto private data structures 2 * 3 * Copyright (c) 2022 Eivind Nss. 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 #ifndef PPP_CRYPTO_PRIV_H 30 #define PPP_CRYPTO_PRIV_H 31 32 #include "crypto.h" 33 34 #define MAX_KEY_SIZE 32 35 #define MAX_IV_SIZE 32 36 37 struct _PPP_MD 38 { 39 int (*init_fn)(PPP_MD_CTX *ctx); 40 int (*update_fn)(PPP_MD_CTX *ctx, const void *data, size_t cnt); 41 int (*final_fn)(PPP_MD_CTX *ctx, unsigned char *out, unsigned int *outlen); 42 void (*clean_fn)(PPP_MD_CTX *ctx); 43 }; 44 45 struct _PPP_MD_CTX 46 { 47 PPP_MD md; 48 void *priv; 49 }; 50 51 struct _PPP_CIPHER 52 { 53 int (*init_fn)(PPP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv); 54 int (*update_fn)(PPP_CIPHER_CTX *ctx, unsigned char *out, int *outl, const unsigned char *in, int inl); 55 int (*final_fn)(PPP_CIPHER_CTX *ctx, unsigned char *out, int *outl); 56 void (*clean_fn)(PPP_CIPHER_CTX *ctx); 57 }; 58 59 struct _PPP_CIPHER_CTX 60 { 61 PPP_CIPHER cipher; 62 unsigned char key[MAX_KEY_SIZE]; 63 unsigned char iv[MAX_IV_SIZE]; 64 int is_encr; 65 void *priv; 66 }; 67 68 69 #endif 70