# \[ANN\] rasn1 0.2.0 released

**URL:** <https://rubytalk.org/t/ann-rasn1-0-2-0-released/74254>\
**Category:** ruby-talk\
**Created:** [9 August 2017 17:18 UTC](https://rubytalk.org/t/ann-rasn1-0-2-0-released/74254 "2017-08-09T17:18:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sylvain\_Daubert](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@Sylvain\_Daubert](https://rubytalk.org/u/Sylvain_Daubert)\
**Post date:** [9 August 2017 17:18 UTC](https://rubytalk.org/t/ann-rasn1-0-2-0-released/74254/1 "2017-08-09T17:18:22Z")

</div>

rasn1 0.2.0 has been released.

\* home: \<[https://github.com/sdaubert/rasn1](https://github.com/sdaubert/rasn1)\>  
\* bugs: \<[https://github.com/sdaubert/rasn1/issues](https://github.com/sdaubert/rasn1/issues)\>  
\* doc: \<[http://www.rubydoc.info/gems/rasn1](http://www.rubydoc.info/gems/rasn1)\>

RASN1 is a pure ruby ASN.1 library. RASN1 helps to create ASN.1 parsers  
and encoders.

The RASN1::Model class is the entry point to create a parser/encoder.

Simple example:  
From ASN1. definition:

&nbsp;&nbsp;Record ::= SEQUENCE {  
&nbsp;&nbsp;&nbsp;&nbsp;id INTEGER,  
&nbsp;&nbsp;&nbsp;&nbsp;room [0] INTEGER OPTIONAL,  
&nbsp;&nbsp;&nbsp;&nbsp;house [1] INTEGER DEFAULT 0  
&nbsp;&nbsp;}

a model may be defined this way:

class Record \< RASN1::Model  
&nbsp;&nbsp;sequence :record,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;content: [integer(:id),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;integer(:room, implicit: 0, optional: true),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;integer(:house, implicit: 1, default: 0)]  
end

Then, parsing is as simple as:

record = Record.parse(der\_string)  
record[:id] # =\> RASN1::Integer  
record[:id].value # =\> Integer

And encoding:

record[:id].value = 16\_543\_154  
record.to\_der # =\> String

Changes:

### 0.2.0 / 2017-08-09

\* add helpers of all types to define a Model  
\* add a new +model+ helper to nest model  
\* add ANY type  
\* Types::Sequence and Types::Set may now parse a DER string even if they  
have no child. Their value is then set to content portion of DER string  
\* fix a lot of bugs
