ber_put_enum - Linux


Overview

ber_put_enum is a library function in the Botan library used to encode an enumerated value. Botan is a C++ library that provides cryptographic algorithms and protocols.

Syntax

bool ber_put_enum(BER_Output& ber, const ASN1_String& value,
                  ASN1_Tag enum_tag, const std::map<std::string, uint64_t>& enum_map)

Options/Flags

  • value: The enumerated value to be encoded.
  • enum_tag: The ASN.1 tag for the enumeration.
  • enum_map: A map that associates the enumerated values with their corresponding numerical values.

Examples

// Encode the enumerated value "foo" with the ASN.1 tag 1
std::map<std::string, uint64_t> enum_map = {{"foo", 1}, {"bar", 2}};
BER_Output ber;
ber_put_enum(ber, "foo", 1, enum_map);

Common Issues

  • Error: The enumerated value is not found in the enum_map.
  • Solution: Ensure that the enumerated value is present in the enum_map and associated with the correct numerical value.

Integration

ber_put_enum can be used with other Botan functions to encode ASN.1 structures. For example, it can be used to encode the subject field of a certificate.

Related Commands

  • ber_get_enum: Decodes an enumerated value from an ASN.1 structure.
  • ASN1_String: Represents an ASN.1 string.
  • BER_Output: Represents an ASN.1 output.