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