Git Product home page Git Product logo

asinine's Introduction

libasinine

libasinine provides decoding facilities of DER encoded ASN.1 data. Specifically, the library is intended to parse X.509 certificates. The focus is on small size and static memory allocation, making it suitable for use in an embedded environment. In general, you are encouraged to ship libasinine with your code, and link to it statically.

Status

The library is still alpha quality. It (should) parse X.509v1 certificates, v3 is work-in-progress. There are some type conversion routines in asn1-types.c, which allow basic interpretation of the different types. Be warned: libasinine will shoot you in the foot and then run away with the savings you hid under your mattress.

Requirements

Right now, the library itself is quite lightweight. To properly handle ASN.1 time types it requires 64bit unsigned integers. Even slow emulation will do the trick though, and smallish "bignum" support could be added if need be. Also, a compiler like GCC or Clang (on which development happens) is recommended, and the only platform expressly supported. Compiling from git also requires premake4.

Compiling

> premake4 gmake # or other targets, see premake4 --help
> make
> ./tests

Usage

The current API is, of course, subject to change. Have a look at x509.c for a more complex / convoluted example.

#include <asinine/asn1.h>

/* ... */

bool parse_asn1(const uint8_t *data, size_t length)
{
	asn1_parser_t parser;
	asn1_token_t token;

	if (asn1_parser_init(&parser, &token, data, length) < ASININE_OK) {
		// The return code will shed some light on what went wrong
		return false;
	}

	if (asn1_parser_next(&parser) < ASININE_OK) {
		return false;
	}

	// "token" now contains the next token
	if (asn1_is_sequence(&token)) {
		// Do something
	}

	// Iterate over unknown number of children
	asn1_token_t parent = token;

	while (!asn1_parser_eot(&parser, &parent)) {
		// Call asn1_parser_next and then handle the token
	}

	// Yay!
	return true;
}

License

libasinine is licensed unter the Mozilla Public License 2.0, please see LICENSE for details.

The implications are: you can link statically to libasinine, without having to release your own code. Modifications to libasinine have to be made public though.

asinine's People

Contributors

jeremierapin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.