1 /*
2  * keytools.h
3  */
4 
5 #ifndef _KEYTOOLS_H
6 #define _KEYTOOLS_H
7 
8 #ifdef __cplusplus
9 extern          "C" {
10 #endif
11 
12 
13 #define USM_LENGTH_EXPANDED_PASSPHRASE	(1024 * 1024)   /* 1Meg. */
14 
15 #define USM_LENGTH_KU_HASHBLOCK		64      /* In bytes. */
16 
17 #define USM_LENGTH_P_MIN		8       /* In characters. */
18     /*
19      * Recommended practice given in <draft-ietf-snmpv3-usm-v2-02.txt>,
20      * * Section 11.2 "Defining Users".  Move into cmdline app argument
21      * * parsing, and out of the internal routine?  XXX
22      */
23 
24     /*
25      * Prototypes.h
26      */
27     NETSNMP_IMPORT
28     int             generate_Ku(const oid * hashtype, u_int hashtype_len,
29                                 const u_char * P, size_t pplen,
30                                 u_char * Ku, size_t * kulen);
31 
32     NETSNMP_IMPORT
33     int             generate_kul(const oid * hashtype, u_int hashtype_len,
34                                  const u_char * engineID, size_t engineID_len,
35                                  const u_char * Ku, size_t ku_len,
36                                  u_char * Kul, size_t * kul_len);
37 
38     NETSNMP_IMPORT
39     int netsnmp_extend_kul(u_int needKeyLen, oid *hashoid, u_int hashoid_len,
40                            int privType, u_char *engineID, u_int engineIDLen,
41                            u_char **kulBuf, size_t *kulBufLen,
42                            u_int kulBufSize);
43 
44     NETSNMP_IMPORT
45     int             encode_keychange(const oid * hashtype,
46                                      u_int hashtype_len, u_char * oldkey,
47                                      size_t oldkey_len, u_char * newkey,
48                                      size_t newkey_len, u_char * kcstring,
49                                      size_t * kcstring_len);
50 
51     NETSNMP_IMPORT
52     int             decode_keychange(const oid *hashtype, u_int hashtype_len,
53                                      const u_char *oldkey, size_t oldkey_len,
54                                      const u_char *kcstring,
55                                      size_t kcstring_len, u_char *newkey,
56                                      size_t *newkey_len);
57 
58 
59     /*
60      * All functions devolve to the following block if we can't do cryptography
61      */
62 #define	_KEYTOOLS_NOT_AVAILABLE			\
63 {						\
64 	return SNMPERR_KT_NOT_AVAILABLE;	\
65 }
66 
67 #ifdef __cplusplus
68 }
69 #endif
70 #endif                          /* _KEYTOOLS_H */
71