1195972f6Sopenharmony_ci/** 2195972f6Sopenharmony_ci * @file 3195972f6Sopenharmony_ci * Additional SNMPv3 functionality RFC3414 and RFC3826 (internal API, do not use in client code). 4195972f6Sopenharmony_ci */ 5195972f6Sopenharmony_ci 6195972f6Sopenharmony_ci/* 7195972f6Sopenharmony_ci * Copyright (c) 2016 Elias Oenal. 8195972f6Sopenharmony_ci * All rights reserved. 9195972f6Sopenharmony_ci * 10195972f6Sopenharmony_ci * Redistribution and use in source and binary forms, with or without modification, 11195972f6Sopenharmony_ci * are permitted provided that the following conditions are met: 12195972f6Sopenharmony_ci * 13195972f6Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright notice, 14195972f6Sopenharmony_ci * this list of conditions and the following disclaimer. 15195972f6Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright notice, 16195972f6Sopenharmony_ci * this list of conditions and the following disclaimer in the documentation 17195972f6Sopenharmony_ci * and/or other materials provided with the distribution. 18195972f6Sopenharmony_ci * 3. The name of the author may not be used to endorse or promote products 19195972f6Sopenharmony_ci * derived from this software without specific prior written permission. 20195972f6Sopenharmony_ci * 21195972f6Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22195972f6Sopenharmony_ci * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23195972f6Sopenharmony_ci * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24195972f6Sopenharmony_ci * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25195972f6Sopenharmony_ci * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26195972f6Sopenharmony_ci * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27195972f6Sopenharmony_ci * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28195972f6Sopenharmony_ci * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29195972f6Sopenharmony_ci * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30195972f6Sopenharmony_ci * OF SUCH DAMAGE. 31195972f6Sopenharmony_ci * 32195972f6Sopenharmony_ci * Author: Elias Oenal <lwip@eliasoenal.com> 33195972f6Sopenharmony_ci */ 34195972f6Sopenharmony_ci 35195972f6Sopenharmony_ci#ifndef LWIP_HDR_APPS_SNMP_V3_PRIV_H 36195972f6Sopenharmony_ci#define LWIP_HDR_APPS_SNMP_V3_PRIV_H 37195972f6Sopenharmony_ci 38195972f6Sopenharmony_ci#include "lwip/apps/snmp_opts.h" 39195972f6Sopenharmony_ci 40195972f6Sopenharmony_ci#if LWIP_SNMP && LWIP_SNMP_V3 41195972f6Sopenharmony_ci 42195972f6Sopenharmony_ci#include "lwip/apps/snmpv3.h" 43195972f6Sopenharmony_ci#include "snmp_pbuf_stream.h" 44195972f6Sopenharmony_ci 45195972f6Sopenharmony_ci/* According to RFC 3411 */ 46195972f6Sopenharmony_ci#define SNMP_V3_MAX_ENGINE_ID_LENGTH 32 47195972f6Sopenharmony_ci#define SNMP_V3_MAX_USER_LENGTH 32 48195972f6Sopenharmony_ci 49195972f6Sopenharmony_ci#define SNMP_V3_MAX_AUTH_PARAM_LENGTH 12 50195972f6Sopenharmony_ci#define SNMP_V3_MAX_PRIV_PARAM_LENGTH 8 51195972f6Sopenharmony_ci 52195972f6Sopenharmony_ci#define SNMP_V3_MD5_LEN 16 53195972f6Sopenharmony_ci#define SNMP_V3_SHA_LEN 20 54195972f6Sopenharmony_ci 55195972f6Sopenharmony_citypedef enum { 56195972f6Sopenharmony_ci SNMP_V3_PRIV_MODE_DECRYPT = 0, 57195972f6Sopenharmony_ci SNMP_V3_PRIV_MODE_ENCRYPT = 1 58195972f6Sopenharmony_ci} snmpv3_priv_mode_t; 59195972f6Sopenharmony_ci 60195972f6Sopenharmony_cis32_t snmpv3_get_engine_boots_internal(void); 61195972f6Sopenharmony_cierr_t snmpv3_auth(struct snmp_pbuf_stream *stream, u16_t length, const u8_t *key, snmpv3_auth_algo_t algo, u8_t *hmac_out); 62195972f6Sopenharmony_cierr_t snmpv3_crypt(struct snmp_pbuf_stream *stream, u16_t length, const u8_t *key, 63195972f6Sopenharmony_ci const u8_t *priv_param, const u32_t engine_boots, const u32_t engine_time, snmpv3_priv_algo_t algo, snmpv3_priv_mode_t mode); 64195972f6Sopenharmony_cierr_t snmpv3_build_priv_param(u8_t *priv_param); 65195972f6Sopenharmony_civoid snmpv3_enginetime_timer(void *arg); 66195972f6Sopenharmony_ci 67195972f6Sopenharmony_ci#endif 68195972f6Sopenharmony_ci 69195972f6Sopenharmony_ci#endif /* LWIP_HDR_APPS_SNMP_V3_PRIV_H */ 70