--- /dev/null
+##
+# Script to generate ASN.1 source code.
+# If asn1 compiler is not installed get it and install it.
+#
+##
+
+import os
+
+Import('env')
+
+asn1_env = env.Clone()
+
+target_os = asn1_env.get('TARGET_OS')
+src_dir = asn1_env.get('SRC_DIR')
+
+targets_need_asn1 = ['linux']
+asn1c_dir = src_dir + '/extlibs/asn1cert/asn1c-0.9.27'
+asn1c_gz_file = src_dir + '/extlibs/asn1cert/asn1c-0.9.27.tar.gz'
+asn1c_url = 'http://lionet.info/soft/asn1c-0.9.27.tar.gz'
+asn1c_file = src_dir + '/extlibs/asn1cert/asn1c-0.9.27/asn1c/asn1c'
+
+if target_os in targets_need_asn1:
+ print '*** Checking for installation of asn1c-0.9.27 ***'
+
+ if not os.path.exists(asn1c_dir):
+ # If the asn1 gz file is not already present, download it
+ if not os.path.exists(asn1c_gz_file):
+ asn1c_gz = asn1_env.Download(asn1c_gz_file, asn1c_url)
+ else:
+ asn1c_gz = asn1c_gz_file
+
+ # Ungz asn1c
+ print 'Unzipping asn1 compiler'
+ asn1_env.UnpackAll(asn1c_dir, asn1c_gz)
+ if os.path.exists(asn1c_dir):
+ if not os.path.exists(asn1c_file):
+ # Run configure on asn1
+ print 'Configuring asn1 compiler'
+ if asn1_env.get('CROSS_COMPILE'):
+ asn1_env.Configure(asn1c_dir, './configure --host=' + asn1_env['CROSS_COMPILE'])
+ else:
+ asn1_env.Configure(asn1c_dir, './configure')
+
+ # Run make on asn1
+ print 'Making asn1 compiler'
+ asn1_env.Configure(asn1c_dir, 'make')
+ print 'Generating Source Code:'
+ asn1_env.Configure(src_dir + '/extlibs/asn1cert', './asn1c-0.9.27/asn1c/asn1c certificate.asn')
+ asn1_env.Configure(src_dir + '/extlibs/asn1cert', './asn1c-0.9.27/asn1c/asn1c crl.asn')
+ asn1_env.Configure(src_dir + '/extlibs/asn1cert', './asn1c-0.9.27/asn1c/asn1c csr.asn')
+
+
+
--- /dev/null
+CERTIFICATE DEFINITIONS ::= BEGIN\r
+\r
+Certificate ::= SEQUENCE {\r
+ tbsCertificate TBSCertificate,\r
+ signatureAlgorithm AlgorithmIdentifier,\r
+ signatureValue BIT STRING\r
+}\r
+\r
+AlgorithmIdentifier ::= SEQUENCE {\r
+ algorithm OBJECT IDENTIFIER,\r
+ id-ecPublicKey OBJECT IDENTIFIER OPTIONAL,\r
+ nul NULL OPTIONAL\r
+}\r
+\r
+TBSCertificate ::= SEQUENCE {\r
+ version [0] EXPLICIT Version DEFAULT v1,\r
+ serialNumber CertificateSerialNumber,\r
+ signature AlgorithmIdentifier,\r
+ issuer Name,\r
+ validity Validity,\r
+ subject Name,\r
+ subjectPublicKeyInfo SubjectPublicKeyInfo\r
+}\r
+\r
+Version ::= INTEGER { v1(0), v2(1), v3(2) }\r
+\r
+CertificateSerialNumber ::= INTEGER\r
+\r
+Name ::= RDNSequence\r
+\r
+RDNSequence ::= SEQUENCE OF RelativeDistinguishedName\r
+\r
+RelativeDistinguishedName ::= SET OF AttributeTypeAndValue\r
+\r
+AttributeTypeAndValue ::= SEQUENCE {\r
+ type AttributeType,\r
+ value AttributeValue}\r
+\r
+AttributeType ::= OBJECT IDENTIFIER\r
+\r
+AttributeValue ::= UTF8String\r
+\r
+Validity ::= SEQUENCE {\r
+ notBefore Time,\r
+ notAfter Time\r
+}\r
+\r
+Time ::= UTCTime\r
+\r
+SubjectPublicKeyInfo ::= SEQUENCE {\r
+ algorithm AlgorithmIdentifier,\r
+ subjectPublicKey BIT STRING\r
+}\r
+\r
+ECDSA-Sig-Value ::= SEQUENCE {\r
+ r INTEGER,\r
+ s INTEGER\r
+}\r
+\r
+END\r
+
--- /dev/null
+CRL DEFINITIONS ::= BEGIN
+
+CertificateRevocationList ::= SEQUENCE {
+ tbsCertList TBSCertList,
+ signatureAlgorithm AlgorithmIdentifier,
+ signatureValue BIT STRING }
+
+TBSCertList ::= SEQUENCE {
+ signature AlgorithmIdentifier,
+ issuer Name,
+ thisUpdate Time,
+ revokedCertificates SEQUENCE OF CertificateRevocationInfo
+ }
+
+CertificateRevocationInfo ::= SEQUENCE {
+ userCertificate CertificateSerialNumber,
+ revocationDate Time
+ }
+
+AlgorithmIdentifier ::= SEQUENCE {
+ algorithm OBJECT IDENTIFIER,
+ id-ecPublicKey OBJECT IDENTIFIER OPTIONAL,
+ nul NULL OPTIONAL
+}
+
+CertificateSerialNumber ::= INTEGER
+
+Time ::= UTCTime
+
+Name ::= RDNSequence
+
+RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
+
+RelativeDistinguishedName ::= SET OF AttributeTypeAndValue
+
+AttributeTypeAndValue ::= SEQUENCE {
+ type AttributeType,
+ value AttributeValue }
+
+AttributeType ::= OBJECT IDENTIFIER
+
+AttributeValue ::= UTF8String
+
+END
+
--- /dev/null
+CSR DEFINITIONS ::= BEGIN
+
+-- Certificate requests
+
+CertificationRequest ::= SEQUENCE {
+ certificationRequestInfo CertificationRequestInfo,
+ signatureAlgorithm AlgorithmIdentifier,
+ signature BIT STRING
+}
+
+CertificationRequestInfo ::= SEQUENCE {
+ version INTEGER { v1(0) },
+ subject Name,
+ subjectPKInfo SubjectPublicKeyInfo
+}
+
+SubjectPublicKeyInfo ::= SEQUENCE {
+ algorithm AlgorithmIdentifier,
+ subjectPublicKey BIT STRING
+}
+
+AlgorithmIdentifier ::= SEQUENCE {
+ algorithm OBJECT IDENTIFIER,
+ id-ecPublicKey OBJECT IDENTIFIER OPTIONAL,
+ nul NULL OPTIONAL
+}
+
+Name ::= RDNSequence
+
+RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
+
+RelativeDistinguishedName ::= SET OF AttributeTypeAndValue
+
+AttributeTypeAndValue ::= SEQUENCE {
+ type AttributeType,
+ value AttributeValue }
+
+AttributeType ::= OBJECT IDENTIFIER
+
+AttributeValue ::= UTF8String
+
+END