MCPcopy Create free account
hub / github.com/F-Stack/f-stack / key_dup_keymsg

Function key_dup_keymsg

freebsd/netipsec/key.c:4047–4070  ·  view source on GitHub ↗

%%% utilities */ Take a key message (sadb_key) from the socket and turn it into one * of the kernel's key structures (seckey). * * IN: pointer to the src * OUT: NULL no more memory */

Source from the content-addressed store, hash-verified

4045 * OUT: NULL no more memory
4046 */
4047struct seckey *
4048key_dup_keymsg(const struct sadb_key *src, size_t len,
4049 struct malloc_type *type)
4050{
4051 struct seckey *dst;
4052
4053 dst = malloc(sizeof(*dst), type, M_NOWAIT);
4054 if (dst != NULL) {
4055 dst->bits = src->sadb_key_bits;
4056 dst->key_data = malloc(len, type, M_NOWAIT);
4057 if (dst->key_data != NULL) {
4058 bcopy((const char *)(src + 1), dst->key_data, len);
4059 } else {
4060 ipseclog((LOG_DEBUG, "%s: No more memory.\n",
4061 __func__));
4062 free(dst, type);
4063 dst = NULL;
4064 }
4065 } else {
4066 ipseclog((LOG_DEBUG, "%s: No more memory.\n",
4067 __func__));
4068 }
4069 return (dst);
4070}
4071
4072/* Take a lifetime message (sadb_lifetime) passed in on a socket and
4073 * turn it into one of the kernel's lifetime structures (seclifetime).

Callers 1

key_setsavalFunction · 0.85

Calls 2

mallocFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected