/**
 * @file       der.h
 * @brief      Simple DER iterator to parse x.509 certificate.
 * @author     Oleksandr Fadieiev (o.fadieiev@samsung.com)
 * @version    1.0
 * @date       Created April 19, 2017
 * @copyright  In Samsung Ukraine R&D Center (SURC) under a contract between
 * @par        LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine) and
 * @par        "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
 * @par        Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
 */
#ifndef _SOURCES_DER_H_
#define _SOURCES_DER_H_

#include <stdint.h>

typedef struct __attribute__((packed)) {
  uint8_t tag;
  uint8_t length[];
} DerHeader;

enum {
  kDerConstructed = 0x20
};

enum {
  kDerInteger = 0x02,
  kDerSimpleBitString = 0x03,
  kDerSequence = 0x30
};

uint8_t DerTag(const DerHeader *der);
uint16_t DerLength(const DerHeader *der);
void *DerValue(const DerHeader *der);
DerHeader *DerNext(const DerHeader *current, const void *end);

#endif // _SOURCES_DER_H_
