The new function accepts additional flags to be used during deinitialization.
For the moment the only available flag is ASN1_DELETE_FLAG_ZEROIZE which zeroizes
all values in the structure prior to deinitialization.
GNU Libtasn1 NEWS -*- outline -*-
* Noteworthy changes in release 3.4 (unreleased) [stable]
+- Added asn1_delete_structure2() which allows zeroizing the contents
+ of all values in the structure prior to deinitialization.
* Noteworthy changes in release 3.3 (released 2013-03-23) [stable]
- More precise overflow checks using gnulib's intprops module.
#define ASN1_ETYPE_UTC_TIME 36
#define ASN1_ETYPE_GENERALIZED_TIME 37
+/* Flags used by asn1_delete_structure2() */
+
+/* makes sure the values are zeroized prior to deinitialization */
+#define ASN1_DELETE_FLAG_ZEROIZE 1
+
+
struct asn1_data_node_st
{
const char *name; /* Node name */
extern ASN1_API int asn1_delete_structure (asn1_node * structure);
+ extern ASN1_API int asn1_delete_structure2 (asn1_node * structure, unsigned int flags);
+
extern ASN1_API int
asn1_delete_element (asn1_node structure, const char *element_name);
/* element (not the elements pointed by it). */
/* Parameters: */
/* node: NODE_ASN element pointer. */
+/* flags: ASN1_DELETE_FLAG_* */
/******************************************************************/
void
-_asn1_remove_node (asn1_node node)
+_asn1_remove_node (asn1_node node, unsigned int flags)
{
if (node == NULL)
return;
+
+ if (flags & ASN1_DELETE_FLAG_ZEROIZE)
+ memset(node->value, 0, node->value_len);
if (node->value != NULL && node->value != node->small_value)
free (node->value);
{
listElement = firstElement;
firstElement = firstElement->next;
- _asn1_remove_node (listElement->node);
+ _asn1_remove_node (listElement->node, 0);
free (listElement);
}
}
|| !(p3->type & CONST_ASSIGN))
return ASN1_ELEMENT_NOT_FOUND;
_asn1_set_down (p, p2->right);
- _asn1_remove_node (p2);
+ _asn1_remove_node (p2, 0);
p2 = p;
p4 = p3->down;
while (p4)
asn1_node _asn1_get_last_right (asn1_node node);
-void _asn1_remove_node (asn1_node node);
+void _asn1_remove_node (asn1_node node, unsigned int flags);
void _asn1_delete_list (void);
int
asn1_delete_structure (asn1_node * structure)
{
+ return asn1_delete_structure2(structure, 0);
+}
+
+/**
+ * asn1_delete_structure2:
+ * @structure: pointer to the structure that you want to delete.
+ * @flags: additional flags (see %ASN1_DELETE_FLAG)
+ *
+ * Deletes the structure *@structure. At the end, *@structure is set
+ * to NULL.
+ *
+ * Returns: %ASN1_SUCCESS if successful, %ASN1_ELEMENT_NOT_FOUND if
+ * *@structure was NULL.
+ **/
+int
+asn1_delete_structure2 (asn1_node * structure, unsigned int flags)
+{
asn1_node p, p2, p3;
if (*structure == NULL)
{
p3 = _asn1_find_up (p);
_asn1_set_down (p3, p2);
- _asn1_remove_node (p);
+ _asn1_remove_node (p, flags);
p = p3;
}
else
}
else
_asn1_set_right (p3, p2);
- _asn1_remove_node (p);
+ _asn1_remove_node (p, flags);
p = NULL;
}
}
if (p == *node)
*node = p2;
- _asn1_remove_node (p);
+ _asn1_remove_node (p, 0);
p = p2;
move = DOWN;
continue;