Skip to content

Commit 0a4d121

Browse files
committed
Add function to get authorityKeyId from certificate
1 parent 2ad2162 commit 0a4d121

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/ECP256Certificate.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* INCLUDE
1313
******************************************************************************/
1414

15+
#define _GNU_SOURCE
16+
#include <string.h>
1517
#include "ECP256Certificate.h"
1618

1719
/******************************************************************************
@@ -384,6 +386,17 @@ int ECP256Certificate::setSignature(const byte* signature, int signatureLen) {
384386
return 0;
385387
}
386388

389+
const byte * ECP256Certificate::authorityKeyId() const {
390+
static const byte objectId[] = {0x06, 0x03, 0x55, 0x1D, 0x23};
391+
byte * result = nullptr;
392+
void * ptr = memmem(_certBuffer, _certBufferLen, objectId, sizeof(objectId));
393+
if (ptr != nullptr) {
394+
result = (byte*)ptr;
395+
result += 11;
396+
}
397+
return result;
398+
}
399+
387400
/******************************************************************************
388401
* PRIVATE MEMBER FUNCTIONS
389402
******************************************************************************/

src/ECP256Certificate.h

+3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ class ECP256Certificate {
6868
inline byte* bytes() { return _certBuffer; }
6969
inline int length() { return _certBufferLen; }
7070

71+
/* Parsing Helpers */
72+
const byte * authorityKeyId() const;
73+
7174
#if defined(SECURE_ELEMENT_IS_ECCX08)
7275
/* Get Data to create ECCX08 compressed cert */
7376
inline byte* compressedCertBytes() { return _compressedCert.data; }

0 commit comments

Comments
 (0)