oid.h
Go to the documentation of this file.
1/**
2 * @file oid.h
3 * @brief OID (Object Identifier)
4 *
5 * @section License
6 *
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 *
9 * Copyright (C) 2010-2021 Oryx Embedded SARL. All rights reserved.
10 *
11 * This file is part of CycloneCRYPTO Open.
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software Foundation,
25 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 *
27 * @author Oryx Embedded SARL (www.oryx-embedded.com)
28 * @version 2.1.2
29 **/
30
31#ifndef _OID_H
32#define _OID_H
33
34//Dependencies
35#include "core/crypto.h"
36
37//Mask definition
38#define OID_MORE_FLAG 0x80
39#define OID_VALUE_MASK 0x7F
40
41//C++ guard
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46//OID related functions
47error_t oidCheck(const uint8_t *oid, size_t oidLen);
48
49int_t oidComp(const uint8_t *oid1, size_t oidLen1, const uint8_t *oid2,
50 size_t oidLen2);
51
52bool_t oidMatch(const uint8_t *oid, size_t oidLen, const uint8_t *subtree,
53 size_t subtreeLen, const uint8_t *mask, size_t maskLen);
54
55uint_t oidCountSubIdentifiers(const uint8_t *oid, size_t oidLen);
56
57error_t oidEncodeSubIdentifier(uint8_t *oid, size_t maxOidLen,
58 size_t *pos, uint32_t value);
59
60error_t oidDecodeSubIdentifier(const uint8_t *oid, size_t oidLen,
61 size_t *pos, uint32_t *value);
62
63error_t oidFromString(const char_t *str, uint8_t *oid, size_t maxOidLen,
64 size_t *oidLen);
65
66char_t *oidToString(const uint8_t *oid, size_t oidLen, char_t *str,
67 size_t maxStrLen);
68
69error_t maskFromString(const char_t *str, uint8_t *mask, size_t maxMaskLen,
70 size_t *maskLen);
71
72//C++ guard
73#ifdef __cplusplus
74}
75#endif
76
77#endif
signed int int_t
Definition: compiler_port.h:44
unsigned int uint_t
Definition: compiler_port.h:45
char char_t
Definition: compiler_port.h:43
int bool_t
Definition: compiler_port.h:49
General definitions for cryptographic algorithms.
uint8_t value[]
Definition: dtls_misc.h:150
error_t
Error codes.
Definition: error.h:43
uint8_t oid[1]
Definition: mib_common.h:186
uint_t oidCountSubIdentifiers(const uint8_t *oid, size_t oidLen)
Calculate the number of sub-identifiers.
Definition: oid.c:289
error_t oidDecodeSubIdentifier(const uint8_t *oid, size_t oidLen, size_t *pos, uint32_t *value)
Decode OID sub-identifier.
Definition: oid.c:378
error_t oidFromString(const char_t *str, uint8_t *oid, size_t maxOidLen, size_t *oidLen)
Convert a string representation of an OID to a binary OID.
Definition: oid.c:422
int_t oidComp(const uint8_t *oid1, size_t oidLen1, const uint8_t *oid2, size_t oidLen2)
Compare object identifiers.
Definition: oid.c:103
error_t oidEncodeSubIdentifier(uint8_t *oid, size_t maxOidLen, size_t *pos, uint32_t value)
Encode OID sub-identifier.
Definition: oid.c:330
error_t oidCheck(const uint8_t *oid, size_t oidLen)
Check whether the specified object identifier is valid.
Definition: oid.c:50
bool_t oidMatch(const uint8_t *oid, size_t oidLen, const uint8_t *subtree, size_t subtreeLen, const uint8_t *mask, size_t maskLen)
Check whether an OID matches the specified subtree.
Definition: oid.c:148
char_t * oidToString(const uint8_t *oid, size_t oidLen, char_t *str, size_t maxStrLen)
Convert a binary OID to a string representation.
Definition: oid.c:562
error_t maskFromString(const char_t *str, uint8_t *mask, size_t maxMaskLen, size_t *maskLen)
Convert a bit mask to binary representation.
Definition: oid.c:649
uint8_t mask
Definition: web_socket.h:317