| 1 |
/* |
| 2 |
* Note: this file originally auto-generated by mib2c using |
| 3 |
* version : 1.20 $ of : mfd-data-get.m2c,v $ |
| 4 |
* |
| 5 |
* $Id$ |
| 6 |
*/ |
| 7 |
/* |
| 8 |
* standard Net-SNMP includes |
| 9 |
*/ |
| 10 |
#include <net-snmp/net-snmp-config.h> |
| 11 |
#include <net-snmp/library/openssl_config.h> |
| 12 |
#include <net-snmp/net-snmp-includes.h> |
| 13 |
#include <net-snmp/library/snmp_openssl.h> |
| 14 |
#include <net-snmp/agent/net-snmp-agent-includes.h> |
| 15 |
|
| 16 |
/* |
| 17 |
* include our parent header |
| 18 |
*/ |
| 19 |
#define NEED_USMDH_FUNCTIONS |
| 20 |
#include "usmDHUserKeyTable.h" |
| 21 |
#include "snmp-usm-dh-objects-mib/usmDHParameters/usmDHParameters.h" |
| 22 |
|
| 23 |
|
| 24 |
DH * |
| 25 |
usmDHGetUserDHptr(struct usmUser *user, int for_auth_key) |
| 26 |
{ |
| 27 |
DH *dh, *dh_params; |
| 28 |
const BIGNUM *g, *p; |
| 29 |
void **theptr; |
| 30 |
|
| 31 |
if (user == NULL) |
| 32 |
return NULL; |
| 33 |
|
| 34 |
if (for_auth_key == 1) |
| 35 |
theptr = &user->usmDHUserAuthKeyChange; |
| 36 |
else |
| 37 |
theptr = &user->usmDHUserPrivKeyChange; |
| 38 |
|
| 39 |
if (!*theptr) { |
| 40 |
/* |
| 41 |
* copy the system parameters to the local ones |
| 42 |
*/ |
| 43 |
dh = DH_new(); |
| 44 |
if (!dh) |
| 45 |
return NULL; |
| 46 |
dh_params = get_dh_params(); |
| 47 |
if (!dh_params) |
| 48 |
return NULL; |
| 49 |
DH_get0_pqg(dh_params, &p, NULL, &g); |
| 50 |
DH_set0_pqg(dh, BN_dup(p), NULL, BN_dup(g)); |
| 51 |
DH_get0_pqg(dh, &p, NULL, &g); |
| 52 |
if (!g || !p) |
| 53 |
return NULL; |
| 54 |
DH_generate_key(dh); |
| 55 |
*theptr = dh; |
| 56 |
} else { |
| 57 |
dh = (DH *) * theptr; |
| 58 |
} |
| 59 |
return dh; |
| 60 |
} |
| 61 |
|
| 62 |
int |
| 63 |
usmDHGetUserKeyChange(struct usmUser *user, int for_auth_key, |
| 64 |
u_char **keyobj, size_t *keyobj_len) |
| 65 |
{ |
| 66 |
DH *dh = NULL; |
| 67 |
const BIGNUM *pub_key = NULL; |
| 68 |
|
| 69 |
dh = usmDHGetUserDHptr(user, for_auth_key); |
| 70 |
|
| 71 |
if (!dh) { |
| 72 |
snmp_log(LOG_ERR, "ack... shouldn't get here: %p %d\n", |
| 73 |
user, for_auth_key); |
| 74 |
return MFD_ERROR; |
| 75 |
} |
| 76 |
|
| 77 |
DH_get0_key(dh, &pub_key, NULL); |
| 78 |
*keyobj_len = BN_num_bytes(pub_key); |
| 79 |
*keyobj = malloc(*keyobj_len); |
| 80 |
BN_bn2bin(pub_key, *keyobj); |
| 81 |
|
| 82 |
return MFD_SUCCESS; |
| 83 |
} |
| 84 |
|
| 85 |
/** @ingroup data_access |
| 86 |
* @defgroup data_get data_get: Routines to get data |
| 87 |
* |
| 88 |
* TODO:230:M: Implement usmDHUserKeyTable get routines. |
| 89 |
* TODO:240:M: Implement usmDHUserKeyTable mapping routines (if any). |
| 90 |
* |
| 91 |
* These routine are used to get the value for individual objects. The |
| 92 |
* row context is passed, along with a pointer to the memory where the |
| 93 |
* value should be copied. |
| 94 |
* |
| 95 |
* @{ |
| 96 |
*/ |
| 97 |
/********************************************************************** |
| 98 |
********************************************************************** |
| 99 |
*** |
| 100 |
*** Table usmDHUserKeyTable |
| 101 |
*** |
| 102 |
********************************************************************** |
| 103 |
**********************************************************************/ |
| 104 |
/* |
| 105 |
* SNMP-USM-DH-OBJECTS-MIB::usmDHUserKeyTable is subid 2 of usmDHPublicObjects. |
| 106 |
* Its status is Current. |
| 107 |
* OID: .1.3.6.1.3.101.1.1.2, length: 9 |
| 108 |
*/ |
| 109 |
|
| 110 |
/* |
| 111 |
* --------------------------------------------------------------------- |
| 112 |
* * TODO:200:r: Implement usmDHUserKeyTable data context functions. |
| 113 |
*/ |
| 114 |
/* |
| 115 |
* usmDHUserKeyTable_allocate_data |
| 116 |
* |
| 117 |
* Purpose: create new usmDHUserKeyTable_data. |
| 118 |
*/ |
| 119 |
usmDHUserKeyTable_data * |
| 120 |
usmDHUserKeyTable_allocate_data(void) |
| 121 |
{ |
| 122 |
/* |
| 123 |
* TODO:201:r: |-> allocate memory for the usmDHUserKeyTable data context. |
| 124 |
*/ |
| 125 |
usmDHUserKeyTable_data *rtn = |
| 126 |
SNMP_MALLOC_TYPEDEF(usmDHUserKeyTable_data); |
| 127 |
|
| 128 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_allocate_data", "called\n")); |
| 129 |
|
| 130 |
if (NULL == rtn) { |
| 131 |
snmp_log(LOG_ERR, "unable to malloc memory for new " |
| 132 |
"usmDHUserKeyTable_data.\n"); |
| 133 |
} else { |
| 134 |
/* |
| 135 |
* not real user, not in a list. mark for testing |
| 136 |
*/ |
| 137 |
rtn->next = (struct usmUser *) -1; |
| 138 |
rtn->prev = (struct usmUser *) -1; |
| 139 |
} |
| 140 |
return rtn; |
| 141 |
} /* usmDHUserKeyTable_allocate_data */ |
| 142 |
|
| 143 |
/* |
| 144 |
* usmDHUserKeyTable_release_data |
| 145 |
* |
| 146 |
* Purpose: release usmDHUserKeyTable data. |
| 147 |
*/ |
| 148 |
void |
| 149 |
usmDHUserKeyTable_release_data(usmDHUserKeyTable_data * data) |
| 150 |
{ |
| 151 |
struct usmUser *user = data; |
| 152 |
|
| 153 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_release_data", |
| 154 |
"called\n")); |
| 155 |
|
| 156 |
netsnmp_assert(user->next == (struct usmUser *) -1); |
| 157 |
netsnmp_assert(user->prev == (struct usmUser *) -1); |
| 158 |
|
| 159 |
usm_free_user(user); |
| 160 |
} /* usmDHUserKeyTable_release_data */ |
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
/** |
| 165 |
* set mib index(es) |
| 166 |
* |
| 167 |
* @param tbl_idx mib index structure |
| 168 |
* @param usmUserEngineID_val_ptr |
| 169 |
* @param usmUserEngineID_val_ptr_len |
| 170 |
* @param usmUserName_val_ptr |
| 171 |
* @param usmUserName_val_ptr_len |
| 172 |
* |
| 173 |
* @retval MFD_SUCCESS : success. |
| 174 |
* @retval MFD_ERROR : other error. |
| 175 |
* |
| 176 |
* @remark |
| 177 |
* This convenience function is useful for setting all the MIB index |
| 178 |
* components with a single function call. It is assume that the C values |
| 179 |
* have already been mapped from their native/rawformat to the MIB format. |
| 180 |
*/ |
| 181 |
int |
| 182 |
usmDHUserKeyTable_indexes_set_tbl_idx(usmDHUserKeyTable_mib_index * |
| 183 |
tbl_idx, |
| 184 |
u_char *usmUserEngineID_val_ptr, |
| 185 |
size_t usmUserEngineID_val_ptr_len, |
| 186 |
char *usmUserName_val_ptr, |
| 187 |
size_t usmUserName_val_ptr_len) |
| 188 |
{ |
| 189 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_indexes_set_tbl_idx", "called\n")); |
| 190 |
|
| 191 |
/* |
| 192 |
* usmUserEngineID(1)/SnmpEngineID/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h |
| 193 |
*/ |
| 194 |
tbl_idx->usmUserEngineID_len = sizeof(tbl_idx->usmUserEngineID) / sizeof(tbl_idx->usmUserEngineID[0]); /* max length */ |
| 195 |
/** WARNING: this code might not work for struct usmUser */ |
| 196 |
/* |
| 197 |
* make sure there is enough space for usmUserEngineID data |
| 198 |
*/ |
| 199 |
if (tbl_idx->usmUserEngineID_len < usmUserEngineID_val_ptr_len) { |
| 200 |
snmp_log(LOG_ERR, "not enough space for value\n"); |
| 201 |
return MFD_ERROR; |
| 202 |
} |
| 203 |
tbl_idx->usmUserEngineID_len = usmUserEngineID_val_ptr_len; |
| 204 |
memcpy(tbl_idx->usmUserEngineID, usmUserEngineID_val_ptr, |
| 205 |
usmUserEngineID_val_ptr_len * |
| 206 |
sizeof(usmUserEngineID_val_ptr[0])); |
| 207 |
|
| 208 |
/* |
| 209 |
* usmUserName(2)/SnmpAdminString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H |
| 210 |
*/ |
| 211 |
tbl_idx->usmUserName_len = sizeof(tbl_idx->usmUserName) / sizeof(tbl_idx->usmUserName[0]); /* max length */ |
| 212 |
|
| 213 |
/** WARNING: this code might not work for struct usmUser */ |
| 214 |
/* |
| 215 |
* make sure there is enough space for usmUserName data |
| 216 |
*/ |
| 217 |
if (tbl_idx->usmUserName_len < usmUserName_val_ptr_len) { |
| 218 |
snmp_log(LOG_ERR, "not enough space for value\n"); |
| 219 |
return MFD_ERROR; |
| 220 |
} |
| 221 |
tbl_idx->usmUserName_len = usmUserName_val_ptr_len; |
| 222 |
memcpy(tbl_idx->usmUserName, usmUserName_val_ptr, |
| 223 |
usmUserName_val_ptr_len * sizeof(usmUserName_val_ptr[0])); |
| 224 |
|
| 225 |
|
| 226 |
return MFD_SUCCESS; |
| 227 |
} /* usmDHUserKeyTable_indexes_set_tbl_idx */ |
| 228 |
|
| 229 |
/** |
| 230 |
* @internal |
| 231 |
* set row context indexes |
| 232 |
* |
| 233 |
* @param reqreq_ctx the row context that needs updated indexes |
| 234 |
* |
| 235 |
* @retval MFD_SUCCESS : success. |
| 236 |
* @retval MFD_ERROR : other error. |
| 237 |
* |
| 238 |
* @remark |
| 239 |
* This function sets the mib indexs, then updates the oid indexs |
| 240 |
* from the mib index. |
| 241 |
*/ |
| 242 |
int |
| 243 |
usmDHUserKeyTable_indexes_set(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx, |
| 244 |
u_char *usmUserEngineID_val_ptr, |
| 245 |
size_t usmUserEngineID_val_ptr_len, |
| 246 |
char *usmUserName_val_ptr, |
| 247 |
size_t usmUserName_val_ptr_len) |
| 248 |
{ |
| 249 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_indexes_set", |
| 250 |
"called\n")); |
| 251 |
|
| 252 |
if (MFD_SUCCESS != |
| 253 |
usmDHUserKeyTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx, |
| 254 |
usmUserEngineID_val_ptr, |
| 255 |
usmUserEngineID_val_ptr_len, |
| 256 |
usmUserName_val_ptr, |
| 257 |
usmUserName_val_ptr_len)) |
| 258 |
return MFD_ERROR; |
| 259 |
|
| 260 |
/* |
| 261 |
* convert mib index to oid index |
| 262 |
*/ |
| 263 |
rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid); |
| 264 |
if (0 != usmDHUserKeyTable_index_to_oid(&rowreq_ctx->oid_idx, |
| 265 |
&rowreq_ctx->tbl_idx)) { |
| 266 |
return MFD_ERROR; |
| 267 |
} |
| 268 |
|
| 269 |
return MFD_SUCCESS; |
| 270 |
} /* usmDHUserKeyTable_indexes_set */ |
| 271 |
|
| 272 |
|
| 273 |
/*--------------------------------------------------------------------- |
| 274 |
* SNMP-USM-DH-OBJECTS-MIB::usmDHUserKeyEntry.usmDHUserAuthKeyChange |
| 275 |
* usmDHUserAuthKeyChange is subid 1 of usmDHUserKeyEntry. |
| 276 |
* Its status is Current, and its access level is Create. |
| 277 |
* OID: .1.3.6.1.3.101.1.1.2.1.1 |
| 278 |
* Description: |
| 279 |
The object used to change any given user's Authentication Key |
| 280 |
using a Diffie-Hellman key exchange. |
| 281 |
|
| 282 |
The right-most n bits of the shared secret 'sk', where 'n' is the |
| 283 |
number of bits required for the protocol defined by |
| 284 |
usmUserAuthProtocol, are installed as the operational |
| 285 |
authentication key for this row after a successful SET. |
| 286 |
* |
| 287 |
* Attributes: |
| 288 |
* accessible 1 isscalar 0 enums 0 hasdefval 0 |
| 289 |
* readable 1 iscolumn 1 ranges 0 hashint 0 |
| 290 |
* settable 1 |
| 291 |
* |
| 292 |
* |
| 293 |
* Its syntax is DHKeyChange (based on perltype OCTETSTR) |
| 294 |
* The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) |
| 295 |
* This data type requires a length. |
| 296 |
*/ |
| 297 |
/** |
| 298 |
* Extract the current value of the usmDHUserAuthKeyChange data. |
| 299 |
* |
| 300 |
* Set a value using the data context for the row. |
| 301 |
* |
| 302 |
* @param rowreq_ctx |
| 303 |
* Pointer to the row request context. |
| 304 |
* @param usmDHUserAuthKeyChange_val_ptr_ptr |
| 305 |
* Pointer to storage for a char variable |
| 306 |
* @param usmDHUserAuthKeyChange_val_ptr_len_ptr |
| 307 |
* Pointer to a size_t. On entry, it will contain the size (in bytes) |
| 308 |
* pointed to by usmDHUserAuthKeyChange. |
| 309 |
* On exit, this value should contain the data size (in bytes). |
| 310 |
* |
| 311 |
* @retval MFD_SUCCESS : success |
| 312 |
* @retval MFD_SKIP : skip this node (no value for now) |
| 313 |
* @retval MFD_ERROR : Any other error |
| 314 |
* |
| 315 |
* @note If you need more than (*usmDHUserAuthKeyChange_val_ptr_len_ptr) bytes of memory, |
| 316 |
* allocate it using malloc() and update usmDHUserAuthKeyChange_val_ptr_ptr. |
| 317 |
* <b>DO NOT</b> free the previous pointer. |
| 318 |
* The MFD helper will release the memory you allocate. |
| 319 |
* |
| 320 |
* @remark If you call this function yourself, you are responsible |
| 321 |
* for checking if the pointer changed, and freeing any |
| 322 |
* previously allocated memory. (Not necessary if you pass |
| 323 |
* in a pointer to static memory, obviously.) |
| 324 |
*/ |
| 325 |
int |
| 326 |
usmDHUserAuthKeyChange_get(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx, |
| 327 |
u_char **usmDHUserAuthKeyChange_val_ptr_ptr, |
| 328 |
size_t *usmDHUserAuthKeyChange_val_ptr_len_ptr) |
| 329 |
{ |
| 330 |
/** we should have a non-NULL pointer and enough storage */ |
| 331 |
netsnmp_assert((NULL != usmDHUserAuthKeyChange_val_ptr_ptr) |
| 332 |
&& (NULL != *usmDHUserAuthKeyChange_val_ptr_ptr)); |
| 333 |
netsnmp_assert(NULL != usmDHUserAuthKeyChange_val_ptr_len_ptr); |
| 334 |
|
| 335 |
|
| 336 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserAuthKeyChange_get", |
| 337 |
"called\n")); |
| 338 |
|
| 339 |
netsnmp_assert(NULL != rowreq_ctx); |
| 340 |
|
| 341 |
/* |
| 342 |
* TODO:231:o: |-> Extract the current value of the usmDHUserAuthKeyChange data. |
| 343 |
* copy (* usmDHUserAuthKeyChange_val_ptr_ptr ) data and (* usmDHUserAuthKeyChange_val_ptr_len_ptr ) from rowreq_ctx->data |
| 344 |
*/ |
| 345 |
if (!rowreq_ctx || !usmDHUserAuthKeyChange_val_ptr_len_ptr || |
| 346 |
!usmDHUserAuthKeyChange_val_ptr_ptr || |
| 347 |
!*usmDHUserAuthKeyChange_val_ptr_ptr) { |
| 348 |
return MFD_ERROR; |
| 349 |
} |
| 350 |
|
| 351 |
return usmDHGetUserKeyChange(rowreq_ctx->data, 1, |
| 352 |
usmDHUserAuthKeyChange_val_ptr_ptr, |
| 353 |
usmDHUserAuthKeyChange_val_ptr_len_ptr); |
| 354 |
} /* usmDHUserAuthKeyChange_get */ |
| 355 |
|
| 356 |
/*--------------------------------------------------------------------- |
| 357 |
* SNMP-USM-DH-OBJECTS-MIB::usmDHUserKeyEntry.usmDHUserOwnAuthKeyChange |
| 358 |
* usmDHUserOwnAuthKeyChange is subid 2 of usmDHUserKeyEntry. |
| 359 |
* Its status is Current, and its access level is Create. |
| 360 |
* OID: .1.3.6.1.3.101.1.1.2.1.2 |
| 361 |
* Description: |
| 362 |
The object used to change the agents own Authentication Key |
| 363 |
using a Diffie-Hellman key exchange. |
| 364 |
|
| 365 |
The right-most n bits of the shared secret 'sk', where 'n' is the |
| 366 |
number of bits required for the protocol defined by |
| 367 |
usmUserAuthProtocol, are installed as the operational |
| 368 |
authentication key for this row after a successful SET. |
| 369 |
* |
| 370 |
* Attributes: |
| 371 |
* accessible 1 isscalar 0 enums 0 hasdefval 0 |
| 372 |
* readable 1 iscolumn 1 ranges 0 hashint 0 |
| 373 |
* settable 1 |
| 374 |
* |
| 375 |
* |
| 376 |
* Its syntax is DHKeyChange (based on perltype OCTETSTR) |
| 377 |
* The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) |
| 378 |
* This data type requires a length. |
| 379 |
*/ |
| 380 |
/** |
| 381 |
* Extract the current value of the usmDHUserOwnAuthKeyChange data. |
| 382 |
* |
| 383 |
* Set a value using the data context for the row. |
| 384 |
* |
| 385 |
* @param rowreq_ctx |
| 386 |
* Pointer to the row request context. |
| 387 |
* @param usmDHUserOwnAuthKeyChange_val_ptr_ptr |
| 388 |
* Pointer to storage for a char variable |
| 389 |
* @param usmDHUserOwnAuthKeyChange_val_ptr_len_ptr |
| 390 |
* Pointer to a size_t. On entry, it will contain the size (in bytes) |
| 391 |
* pointed to by usmDHUserOwnAuthKeyChange. |
| 392 |
* On exit, this value should contain the data size (in bytes). |
| 393 |
* |
| 394 |
* @retval MFD_SUCCESS : success |
| 395 |
* @retval MFD_SKIP : skip this node (no value for now) |
| 396 |
* @retval MFD_ERROR : Any other error |
| 397 |
* |
| 398 |
* @note If you need more than (*usmDHUserOwnAuthKeyChange_val_ptr_len_ptr) bytes of memory, |
| 399 |
* allocate it using malloc() and update usmDHUserOwnAuthKeyChange_val_ptr_ptr. |
| 400 |
* <b>DO NOT</b> free the previous pointer. |
| 401 |
* The MFD helper will release the memory you allocate. |
| 402 |
* |
| 403 |
* @remark If you call this function yourself, you are responsible |
| 404 |
* for checking if the pointer changed, and freeing any |
| 405 |
* previously allocated memory. (Not necessary if you pass |
| 406 |
* in a pointer to static memory, obviously.) |
| 407 |
*/ |
| 408 |
int |
| 409 |
usmDHUserOwnAuthKeyChange_get(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx, |
| 410 |
u_char **usmDHUserOwnAuthKeyChange_val_ptr_ptr, |
| 411 |
size_t |
| 412 |
*usmDHUserOwnAuthKeyChange_val_ptr_len_ptr) |
| 413 |
{ |
| 414 |
/** we should have a non-NULL pointer and enough storage */ |
| 415 |
netsnmp_assert((NULL != usmDHUserOwnAuthKeyChange_val_ptr_ptr) |
| 416 |
&& (NULL != *usmDHUserOwnAuthKeyChange_val_ptr_ptr)); |
| 417 |
netsnmp_assert(NULL != usmDHUserOwnAuthKeyChange_val_ptr_len_ptr); |
| 418 |
|
| 419 |
|
| 420 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserOwnAuthKeyChange_get", |
| 421 |
"called\n")); |
| 422 |
|
| 423 |
netsnmp_assert(NULL != rowreq_ctx); |
| 424 |
|
| 425 |
/* |
| 426 |
* TODO:231:o: |-> Extract the current value of the usmDHUserOwnAuthKeyChange data. |
| 427 |
* copy (* usmDHUserOwnAuthKeyChange_val_ptr_ptr ) data and (* usmDHUserOwnAuthKeyChange_val_ptr_len_ptr ) from rowreq_ctx->data |
| 428 |
*/ |
| 429 |
if (!rowreq_ctx || !usmDHUserOwnAuthKeyChange_val_ptr_len_ptr || |
| 430 |
!usmDHUserOwnAuthKeyChange_val_ptr_ptr || |
| 431 |
!*usmDHUserOwnAuthKeyChange_val_ptr_ptr) { |
| 432 |
return MFD_ERROR; |
| 433 |
} |
| 434 |
|
| 435 |
return usmDHGetUserKeyChange(rowreq_ctx->data, 1, |
| 436 |
usmDHUserOwnAuthKeyChange_val_ptr_ptr, |
| 437 |
usmDHUserOwnAuthKeyChange_val_ptr_len_ptr); |
| 438 |
} /* usmDHUserOwnAuthKeyChange_get */ |
| 439 |
|
| 440 |
/*--------------------------------------------------------------------- |
| 441 |
* SNMP-USM-DH-OBJECTS-MIB::usmDHUserKeyEntry.usmDHUserPrivKeyChange |
| 442 |
* usmDHUserPrivKeyChange is subid 3 of usmDHUserKeyEntry. |
| 443 |
* Its status is Current, and its access level is Create. |
| 444 |
* OID: .1.3.6.1.3.101.1.1.2.1.3 |
| 445 |
* Description: |
| 446 |
The object used to change any given user's Privacy Key using |
| 447 |
a Diffie-Hellman key exchange. |
| 448 |
|
| 449 |
The right-most n bits of the shared secret 'sk', where 'n' is the |
| 450 |
number of bits required for the protocol defined by |
| 451 |
usmUserPrivProtocol, are installed as the operational privacy key |
| 452 |
for this row after a successful SET. |
| 453 |
* |
| 454 |
* Attributes: |
| 455 |
* accessible 1 isscalar 0 enums 0 hasdefval 0 |
| 456 |
* readable 1 iscolumn 1 ranges 0 hashint 0 |
| 457 |
* settable 1 |
| 458 |
* |
| 459 |
* |
| 460 |
* Its syntax is DHKeyChange (based on perltype OCTETSTR) |
| 461 |
* The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) |
| 462 |
* This data type requires a length. |
| 463 |
*/ |
| 464 |
/** |
| 465 |
* Extract the current value of the usmDHUserPrivKeyChange data. |
| 466 |
* |
| 467 |
* Set a value using the data context for the row. |
| 468 |
* |
| 469 |
* @param rowreq_ctx |
| 470 |
* Pointer to the row request context. |
| 471 |
* @param usmDHUserPrivKeyChange_val_ptr_ptr |
| 472 |
* Pointer to storage for a char variable |
| 473 |
* @param usmDHUserPrivKeyChange_val_ptr_len_ptr |
| 474 |
* Pointer to a size_t. On entry, it will contain the size (in bytes) |
| 475 |
* pointed to by usmDHUserPrivKeyChange. |
| 476 |
* On exit, this value should contain the data size (in bytes). |
| 477 |
* |
| 478 |
* @retval MFD_SUCCESS : success |
| 479 |
* @retval MFD_SKIP : skip this node (no value for now) |
| 480 |
* @retval MFD_ERROR : Any other error |
| 481 |
* |
| 482 |
* @note If you need more than (*usmDHUserPrivKeyChange_val_ptr_len_ptr) bytes of memory, |
| 483 |
* allocate it using malloc() and update usmDHUserPrivKeyChange_val_ptr_ptr. |
| 484 |
* <b>DO NOT</b> free the previous pointer. |
| 485 |
* The MFD helper will release the memory you allocate. |
| 486 |
* |
| 487 |
* @remark If you call this function yourself, you are responsible |
| 488 |
* for checking if the pointer changed, and freeing any |
| 489 |
* previously allocated memory. (Not necessary if you pass |
| 490 |
* in a pointer to static memory, obviously.) |
| 491 |
*/ |
| 492 |
int |
| 493 |
usmDHUserPrivKeyChange_get(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx, |
| 494 |
u_char **usmDHUserPrivKeyChange_val_ptr_ptr, |
| 495 |
size_t *usmDHUserPrivKeyChange_val_ptr_len_ptr) |
| 496 |
{ |
| 497 |
/** we should have a non-NULL pointer and enough storage */ |
| 498 |
netsnmp_assert((NULL != usmDHUserPrivKeyChange_val_ptr_ptr) |
| 499 |
&& (NULL != *usmDHUserPrivKeyChange_val_ptr_ptr)); |
| 500 |
netsnmp_assert(NULL != usmDHUserPrivKeyChange_val_ptr_len_ptr); |
| 501 |
|
| 502 |
|
| 503 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserPrivKeyChange_get", |
| 504 |
"called\n")); |
| 505 |
|
| 506 |
netsnmp_assert(NULL != rowreq_ctx); |
| 507 |
|
| 508 |
/* |
| 509 |
* TODO:231:o: |-> Extract the current value of the usmDHUserPrivKeyChange data. |
| 510 |
* copy (* usmDHUserPrivKeyChange_val_ptr_ptr ) data and (* usmDHUserPrivKeyChange_val_ptr_len_ptr ) from rowreq_ctx->data |
| 511 |
*/ |
| 512 |
if (!rowreq_ctx || !usmDHUserPrivKeyChange_val_ptr_len_ptr || |
| 513 |
!usmDHUserPrivKeyChange_val_ptr_ptr || |
| 514 |
!*usmDHUserPrivKeyChange_val_ptr_ptr) { |
| 515 |
return MFD_ERROR; |
| 516 |
} |
| 517 |
|
| 518 |
return usmDHGetUserKeyChange(rowreq_ctx->data, 0, |
| 519 |
usmDHUserPrivKeyChange_val_ptr_ptr, |
| 520 |
usmDHUserPrivKeyChange_val_ptr_len_ptr); |
| 521 |
} /* usmDHUserPrivKeyChange_get */ |
| 522 |
|
| 523 |
/*--------------------------------------------------------------------- |
| 524 |
* SNMP-USM-DH-OBJECTS-MIB::usmDHUserKeyEntry.usmDHUserOwnPrivKeyChange |
| 525 |
* usmDHUserOwnPrivKeyChange is subid 4 of usmDHUserKeyEntry. |
| 526 |
* Its status is Current, and its access level is Create. |
| 527 |
* OID: .1.3.6.1.3.101.1.1.2.1.4 |
| 528 |
* Description: |
| 529 |
The object used to change the agent's own Privacy Key using a |
| 530 |
Diffie-Hellman key exchange. |
| 531 |
|
| 532 |
The right-most n bits of the shared secret 'sk', where 'n' is the |
| 533 |
number of bits required for the protocol defined by |
| 534 |
usmUserPrivProtocol, are installed as the operational privacy key |
| 535 |
for this row after a successful SET. |
| 536 |
* |
| 537 |
* Attributes: |
| 538 |
* accessible 1 isscalar 0 enums 0 hasdefval 0 |
| 539 |
* readable 1 iscolumn 1 ranges 0 hashint 0 |
| 540 |
* settable 1 |
| 541 |
* |
| 542 |
* |
| 543 |
* Its syntax is DHKeyChange (based on perltype OCTETSTR) |
| 544 |
* The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) |
| 545 |
* This data type requires a length. |
| 546 |
*/ |
| 547 |
/** |
| 548 |
* Extract the current value of the usmDHUserOwnPrivKeyChange data. |
| 549 |
* |
| 550 |
* Set a value using the data context for the row. |
| 551 |
* |
| 552 |
* @param rowreq_ctx |
| 553 |
* Pointer to the row request context. |
| 554 |
* @param usmDHUserOwnPrivKeyChange_val_ptr_ptr |
| 555 |
* Pointer to storage for a char variable |
| 556 |
* @param usmDHUserOwnPrivKeyChange_val_ptr_len_ptr |
| 557 |
* Pointer to a size_t. On entry, it will contain the size (in bytes) |
| 558 |
* pointed to by usmDHUserOwnPrivKeyChange. |
| 559 |
* On exit, this value should contain the data size (in bytes). |
| 560 |
* |
| 561 |
* @retval MFD_SUCCESS : success |
| 562 |
* @retval MFD_SKIP : skip this node (no value for now) |
| 563 |
* @retval MFD_ERROR : Any other error |
| 564 |
* |
| 565 |
* @note If you need more than (*usmDHUserOwnPrivKeyChange_val_ptr_len_ptr) bytes of memory, |
| 566 |
* allocate it using malloc() and update usmDHUserOwnPrivKeyChange_val_ptr_ptr. |
| 567 |
* <b>DO NOT</b> free the previous pointer. |
| 568 |
* The MFD helper will release the memory you allocate. |
| 569 |
* |
| 570 |
* @remark If you call this function yourself, you are responsible |
| 571 |
* for checking if the pointer changed, and freeing any |
| 572 |
* previously allocated memory. (Not necessary if you pass |
| 573 |
* in a pointer to static memory, obviously.) |
| 574 |
*/ |
| 575 |
int |
| 576 |
usmDHUserOwnPrivKeyChange_get(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx, |
| 577 |
u_char **usmDHUserOwnPrivKeyChange_val_ptr_ptr, |
| 578 |
size_t |
| 579 |
*usmDHUserOwnPrivKeyChange_val_ptr_len_ptr) |
| 580 |
{ |
| 581 |
/** we should have a non-NULL pointer and enough storage */ |
| 582 |
netsnmp_assert((NULL != usmDHUserOwnPrivKeyChange_val_ptr_ptr) |
| 583 |
&& (NULL != *usmDHUserOwnPrivKeyChange_val_ptr_ptr)); |
| 584 |
netsnmp_assert(NULL != usmDHUserOwnPrivKeyChange_val_ptr_len_ptr); |
| 585 |
|
| 586 |
|
| 587 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserOwnPrivKeyChange_get", |
| 588 |
"called\n")); |
| 589 |
|
| 590 |
netsnmp_assert(NULL != rowreq_ctx); |
| 591 |
|
| 592 |
/* |
| 593 |
* TODO:231:o: |-> Extract the current value of the usmDHUserOwnPrivKeyChange data. |
| 594 |
* copy (* usmDHUserOwnPrivKeyChange_val_ptr_ptr ) data and (* usmDHUserOwnPrivKeyChange_val_ptr_len_ptr ) from rowreq_ctx->data |
| 595 |
*/ |
| 596 |
if (!rowreq_ctx || !usmDHUserOwnPrivKeyChange_val_ptr_len_ptr || |
| 597 |
!usmDHUserOwnPrivKeyChange_val_ptr_ptr || |
| 598 |
!*usmDHUserOwnPrivKeyChange_val_ptr_ptr) { |
| 599 |
return MFD_ERROR; |
| 600 |
} |
| 601 |
|
| 602 |
return usmDHGetUserKeyChange(rowreq_ctx->data, 0, |
| 603 |
usmDHUserOwnPrivKeyChange_val_ptr_ptr, |
| 604 |
usmDHUserOwnPrivKeyChange_val_ptr_len_ptr); |
| 605 |
} /* usmDHUserOwnPrivKeyChange_get */ |
| 606 |
|
| 607 |
|
| 608 |
|
| 609 |
/** @} */ |