Updated Makefiles:
authorRick van Rein <rick@openfortress.nl>
Wed, 18 May 2016 22:34:16 +0000 (23:34 +0100)
committerRick van Rein <rick@openfortress.nl>
Wed, 18 May 2016 22:34:16 +0000 (23:34 +0100)
 - Introduced DESTDIR and PREFIX in main Makefile, but only as defaults
 - Made all subdirs pickup on this contextual setup
 - Created $(DESTDIR)$(PREFIX)/lib/pkgconfig/quick-der.pc

Makefile
arpa2/Makefile [new file with mode: 0644]
itu/Makefile
lib/Makefile
rfc/Makefile
rfc/orig/rfc6960.asn1 [new file with mode: 0644]
tool/Makefile

index d5e3404..daa4044 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,19 +1,24 @@
+DESTDIR ?=
+PREFIX ?= /usr/local
+
 # SUBDIRS = lib asn2qder test rfc arpa2
 SUBDIRS = lib tool test rfc
 
+SUBMAKE=$(MAKE) PREFIX='$(PREFIX)' DESTDIR='$(DESTDIR)'
+
 all:
        #
        # To incorporate subprojects with valuable add-ons, run:
        #
        # git submodule update --init
        #
-       @ $(foreach d,$(SUBDIRS),$(MAKE) -C '$d' all &&) echo "Made all subdirectories"
+       @ $(foreach d,$(SUBDIRS),$(SUBMAKE) -C '$d' all &&) echo "Made all subdirectories"
 
 install:
-       @ $(foreach d,$(SUBDIRS),$(MAKE) -C '$d' all &&) echo "Installed all subdirectories"
+       @ $(foreach d,$(SUBDIRS),$(SUBMAKE) -C '$d' install &&) echo "Installed all subdirectories"
 
 uninstall:
-       @ $(foreach d,$(SUBDIRS),$(MAKE) -C '$d' all &&) echo "Uninstalled all subdirectories"
+       @ $(foreach d,$(SUBDIRS),$(SUBMAKE) -C '$d' uninstall &&) echo "Uninstalled all subdirectories"
 
 clean:
-       @ $(foreach d,$(SUBDIRS),$(MAKE) -C '$d' all &&) echo "Cleaned all subdirectories"
+       @ $(foreach d,$(SUBDIRS),$(SUBMAKE) -C '$d' clean &&) echo "Cleaned all subdirectories"
diff --git a/arpa2/Makefile b/arpa2/Makefile
new file mode 100644 (file)
index 0000000..e0f388e
--- /dev/null
@@ -0,0 +1,70 @@
+#
+# This directory holds .asn1 files derived from the pristine versions in orig/
+# that were adapted (and commented with "--asn1ate" where this is done) to make
+# it pass through the compiler.
+#
+# Current TODO:
+#  - order definitions, the compiler now runs into problems
+#  - check for undefined names, if possible
+#  - map ... to DER_PACK_OPTIONAL, DER_PACK_LEAVE -- and process accordingly
+#
+
+HEADERS = RemotePKCS11.h KXOVER.h
+LITERATE = RemotePKCS11.md RemotePKCS11.rst RemotePKCS11.html RemotePKCS11.epub \
+               RemotePKCS11.tex RemotePKCS11.pdf \
+               KXOVER.md KXOVER.rst KXOVER.html KXOVER.epub KXOVER.tex KXOVER.pdf \
+               KXOVER.txt \
+               CommunicationFilter.md
+TARGETS = $(HEADERS) $(LITERATE)
+
+ASN2QUICKDER_DIR = ../tool/asn1ate
+
+ASN2QUICKDER = PYTHONPATH='$(ASN2QUICKDER_DIR)' $(ASN2QUICKDER_DIR)/asn1ate/asn2quickder.py
+
+ASNLITERATE = ../tool/asn1literate.py 
+
+KXOVER_DEPS = ../rfc/rfc4120.asn1 ../rfc/rfc5280.asn1
+
+all: $(TARGETS) test
+
+test: $(HEADERS)
+       @ $(foreach h,$(HEADERS),echo > '$(h:.h=.c)' '#include "$(h)"' && gcc -c '$(h:.h=.c)' && ) echo 'Passed all header compilation tests'
+
+%.h: %.asn1
+       $(ASN2QUICKDER) '$<' $(foreach f,$($(<:.asn1=_DEPS)),$f)
+
+%.md: %.asn1
+       @ if grep -q '  ' '$<' ; then echo 'Please remove tabs from $<, they mess up the layout' ; exit 1 ; fi
+       $(ASNLITERATE) '$<'
+
+%.txt: %.md
+       @ [ -x /usr/bin/pandoc ] && pandoc --self-contained -o '$@' '$<' || echo Pandoc is not installed -- skipping TeX and PDF generation
+
+%.rst: %.md
+       @ [ -x /usr/bin/pandoc ] && pandoc --self-contained -o '$@' '$<' || echo Pandoc is not installed -- skipping RST generation
+
+%.html: %.md
+       @ [ -x /usr/bin/pandoc ] && pandoc --self-contained -o '$@' '$<' || echo Pandoc is not installed -- skipping HTML generation
+
+%.epub: %.md
+       @ [ -x /usr/bin/pandoc ] && pandoc --self-contained -o '$@' '$<' || echo Pandoc is not installed -- skipping EPUB generation
+
+%.tex: %.md
+       @ [ -x /usr/bin/pandoc ] && pandoc --self-contained -o '$@' '$<' || echo Pandoc is not installed -- skipping TeX and PDF generation
+
+%.pdf: %.tex
+       @ [ -x /usr/bin/pdflatex -a -r '$<' ] && pdflatex '$<' || echo pdfLaTeX is not installed -- skipping PDF generation
+
+clean:
+       rm -f $(TARGETS) $(foreach h,$(TARGETS),$(h:.h=.c) $(h:.h=.o))
+
+anew: clean all
+
+install: all
+       @ mkdir -p $(DESTDIR)$(PREFIX)/include/quick-der
+       @ $(foreach h,$(TARGETS),install '$(h)' '$(DESTDIR)$(PREFIX)/include/quick-der' && ) echo Installed header files
+
+uninstall:
+       @ $(foreach h,$(TARGETS),rm -f '$(DESTDIR)$(PREFIX)/include/quick-der/$(h)' && ) echo Removed header files
+       @ rmdir --ignore-fail-on-non-empty '$(DESTDIR)$(PREFIX)/include/quick-der'
+
index b9dfe7d..37a45fb 100644 (file)
@@ -9,8 +9,6 @@
 #  - map ... to DER_PACK_OPTIONAL, DER_PACK_LEAVE -- and process accordingly
 #
 
-PREFIX = /usr/local
-
 TARGETS = # rfc3280.h rfc4120.h rfc4511.h rfc5280.h
 
 ASN2QUICKDER_DIR = ../tool/asn1ate
@@ -32,10 +30,10 @@ clean:
 anew: clean all
 
 install: all
-       @ mkdir -p $(PREFIX)/include/quick-der
-       @ [ -r $(ASN2QUICKDER_CMD) ] && $(foreach h,$(TARGETS),install '$(h)' '$(PREFIX)/include/quick-der' && ) echo Installed header files
+       @ mkdir -p $(DESTDIR)$(PREFIX)/include/quick-der
+       @ [ -r $(ASN2QUICKDER_CMD) ] && $(foreach h,$(TARGETS),install '$(h)' '$(DESTDIR)$(PREFIX)/include/quick-der' && ) echo Installed header files
 
 uninstall:
-       @ $(foreach h,$(TARGETS),rm -f '$(PREFIX)/include/quick-der/$(h)' && ) echo Removed header files
-       @ rmdir --ignore-fail-on-non-empty '$(PREFIX)/include/quick-der'
+       @ $(foreach h,$(TARGETS),rm -f '$(DESTDIR)$(PREFIX)/include/quick-der/$(h)' && ) echo Removed header files
+       @ rmdir --ignore-fail-on-non-empty '$(DESTDIR)$(PREFIX)/include/quick-der'
 
index 4beecfd..018ae16 100644 (file)
@@ -2,21 +2,23 @@ OBJS = der_pack.o der_prepack.o der_unpack.o der_iterate.o der_walk.o der_skipen
 
 TARGETS = libquickder.a libquickder.so
 
-PREFIX = /usr/local
-
 CFLAGS=-Wall -Wextra -pedantic -Wstrict-prototypes -Wold-style-definition -Wwrite-strings -Wshadow -Wformat -Wformat-security -Wunreachable-code -Wmissing-prototypes
 
 all: $(TARGETS)
 
 install: $(TARGETS)
-       install $(TARGETS) "$(PREFIX)/lib"
-       mkdir -p "$(PREFIX)/include/quick-der"
-       install ../include/quick-der/api.h "$(PREFIX)/include/quick-der"
+       install $(TARGETS) '$(DESTDIR)$(PREFIX)/lib'
+       mkdir -p '$(DESTDIR)$(PREFIX)/include/quick-der'
+       install ../include/quick-der/api.h '$(DESTDIR)$(PREFIX)/include/quick-der'
+       mkdir -p '$(DESTDIR)$(PREFIX)/lib/pkgconfig'
+       ( echo 'prefix=$(PREFIX)' ; echo 'exec_prefix=$${prefix}' ; echo 'includedir=$${prefix}/include' ; echo 'libdir=$${prefix}/lib' ; echo ; echo 'Name: quick-der' ; echo "Description: Quick \`n\' Easy DER library" ; echo 'Version: 0.0' ; echo 'URL: https://github.com/vanrein/quick-der' ; echo 'Cflags: -I$${includedir}' ; echo 'Libs: -L$${libdir} -lquickder' ) > '$(DESTDIR)$(PREFIX)/lib/pkgconfig/quick-der.pc'
 
 uninstall:
-       for f in $(TARGETS); do rm -f "$(PREFIX)/lib/$$f" ; done
-       rm -f "$(PREFIX)/include/quick-der/api.h"
-       rmdir --ignore-fail-on-non-empty "$(PREFIX)/include/quick-der"
+       for f in $(TARGETS); do rm -f "$(DESTDIR)$(PREFIX)/lib/$$f" ; done
+       rm -f '$(DESTDIR)$(PREFIX)/include/quick-der/api.h'
+       rmdir --ignore-fail-on-non-empty '$(DESTDIR)$(PREFIX)/include/quick-der'
+       rm -f '$(DESTDIR)$(PREFIX)/lib/pkgconfig/quick-der.pc'
+       rmdir --ignore-fail-on-non-empty '$(DESTDIR)$(PREFIX)/lib/pkgconfig'
 
 clean:
        rm -f $(OBJS) $(TARGETS)
index 139e997..964ad7c 100644 (file)
@@ -9,8 +9,6 @@
 #  - map ... to DER_PACK_OPTIONAL, DER_PACK_LEAVE -- and process accordingly
 #
 
-PREFIX = /usr/local
-
 TARGETS = rfc3280.h rfc4120.h rfc4511.h rfc5280.h \
        rfc2898.h rfc2315.h rfc5208.h rfc7292.h \
        rfc2578.h
@@ -37,10 +35,10 @@ clean:
 anew: clean all
 
 install: all
-       @ mkdir -p $(PREFIX)/include/quick-der
-       @ [ -r $(ASN2QUICKDER_CMD) ] && $(foreach h,$(TARGETS),install '$(h)' '$(PREFIX)/include/quick-der' && ) echo Installed header files
+       @ mkdir -p $(DESTDIR)$(PREFIX)/include/quick-der
+       @ [ -r $(ASN2QUICKDER_CMD) ] && $(foreach h,$(TARGETS),install '$(h)' '$(DESTDIR)$(PREFIX)/include/quick-der' && ) echo Installed header files
 
 uninstall:
-       @ $(foreach h,$(TARGETS),rm -f '$(PREFIX)/include/quick-der/$(h)' && ) echo Removed header files
-       @ rmdir --ignore-fail-on-non-empty '$(PREFIX)/include/quick-der'
+       @ $(foreach h,$(TARGETS),rm -f '$(DESTDIR)$(PREFIX)/include/quick-der/$(h)' && ) echo Removed header files
+       @ rmdir --ignore-fail-on-non-empty '$(DESTDIR)$(PREFIX)/include/quick-der'
 
diff --git a/rfc/orig/rfc6960.asn1 b/rfc/orig/rfc6960.asn1
new file mode 100644 (file)
index 0000000..c124e1c
--- /dev/null
@@ -0,0 +1,210 @@
+OCSP-2013-08
+    {iso(1) identified-organization(3) dod(6) internet(1) security(5)
+    mechanisms(5) pkix(7) id-mod(0) id-mod-ocsp-2013-08(82)}
+
+DEFINITIONS EXPLICIT TAGS ::=
+
+BEGIN
+
+IMPORTS
+
+Extensions{}, EXTENSION, ATTRIBUTE
+FROM PKIX-CommonTypes-2009 -- From [RFC5912]
+    {iso(1) identified-organization(3) dod(6) internet(1) security(5)
+    mechanisms(5) pkix(7) id-mod(0) id-mod-pkixCommon-02(57)}
+
+AlgorithmIdentifier{}, DIGEST-ALGORITHM, SIGNATURE-ALGORITHM, PUBLIC-KEY
+FROM AlgorithmInformation-2009 -- From [RFC5912]
+    {iso(1) identified-organization(3) dod(6) internet(1) security(5)
+    mechanisms(5) pkix(7) id-mod(0)
+    id-mod-algorithmInformation-02(58)}
+
+AuthorityInfoAccessSyntax, GeneralName, CrlEntryExtensions
+FROM PKIX1Implicit-2009 -- From [RFC5912]
+    {iso(1) identified-organization(3) dod(6) internet(1) security(5)
+    mechanisms(5) pkix(7) id-mod(0) id-mod-pkix1-implicit-02(59)}
+
+Name, CertificateSerialNumber, id-kp, id-ad-ocsp, Certificate
+FROM PKIX1Explicit-2009 -- From [RFC5912]
+    {iso(1) identified-organization(3) dod(6) internet(1) security(5)
+    mechanisms(5) pkix(7) id-mod(0) id-mod-pkix1-explicit-02(51)}
+
+sa-dsaWithSHA1, sa-rsaWithMD2, sa-rsaWithMD5, sa-rsaWithSHA1
+FROM PKIXAlgs-2009 -- From [RFC5912]
+    {iso(1) identified-organization(3) dod(6) internet(1) security(5)
+    mechanisms(5) pkix(7) id-mod(0)
+    id-mod-pkix1-algorithms2008-02(56)};
+
+OCSPRequest     ::=     SEQUENCE {
+    tbsRequest                  TBSRequest,
+    optionalSignature   [0]     EXPLICIT Signature OPTIONAL }
+
+TBSRequest      ::=     SEQUENCE {
+    version             [0] EXPLICIT Version DEFAULT v1,
+    requestorName       [1] EXPLICIT GeneralName OPTIONAL,
+    requestList             SEQUENCE OF Request,
+    requestExtensions   [2] EXPLICIT Extensions {{re-ocsp-nonce |
+                     re-ocsp-response, ...,
+                     re-ocsp-preferred-signature-algorithms}} OPTIONAL }
+
+Signature       ::=     SEQUENCE {
+    signatureAlgorithm   AlgorithmIdentifier
+                             { SIGNATURE-ALGORITHM, {...}},
+    signature            BIT STRING,
+    certs            [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
+
+Version  ::=  INTEGER  {  v1(0) }
+
+Request ::=     SEQUENCE {
+    reqCert                    CertID,
+    singleRequestExtensions    [0] EXPLICIT Extensions
+                                       { {re-ocsp-service-locator,
+                                              ...}} OPTIONAL }
+
+CertID ::= SEQUENCE {
+    hashAlgorithm            AlgorithmIdentifier
+                                 {DIGEST-ALGORITHM, {...}},
+    issuerNameHash     OCTET STRING, -- Hash of issuer's DN
+    issuerKeyHash      OCTET STRING, -- Hash of issuer's public key
+    serialNumber       CertificateSerialNumber }
+
+OCSPResponse ::= SEQUENCE {
+   responseStatus         OCSPResponseStatus,
+   responseBytes          [0] EXPLICIT ResponseBytes OPTIONAL }
+
+OCSPResponseStatus ::= ENUMERATED {
+    successful            (0), -- Response has valid confirmations
+    malformedRequest      (1), -- Illegal confirmation request
+    internalError         (2), -- Internal error in issuer
+    tryLater              (3), -- Try again later
+                               -- (4) is not used
+    sigRequired           (5), -- Must sign the request
+    unauthorized          (6)  -- Request unauthorized
+}
+
+RESPONSE ::= TYPE-IDENTIFIER
+
+ResponseSet RESPONSE ::= {basicResponse, ...}
+
+ResponseBytes ::=       SEQUENCE {
+    responseType        RESPONSE.
+                            &id ({ResponseSet}),
+    response            OCTET STRING (CONTAINING RESPONSE.
+                            &Type({ResponseSet}{@responseType}))}
+
+basicResponse RESPONSE ::=
+    { BasicOCSPResponse IDENTIFIED BY id-pkix-ocsp-basic }
+
+BasicOCSPResponse       ::= SEQUENCE {
+   tbsResponseData      ResponseData,
+   signatureAlgorithm   AlgorithmIdentifier{SIGNATURE-ALGORITHM,
+                            {sa-dsaWithSHA1 | sa-rsaWithSHA1 |
+                                 sa-rsaWithMD5 | sa-rsaWithMD2, ...}},
+   signature            BIT STRING,
+   certs            [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
+
+ResponseData ::= SEQUENCE {
+   version              [0] EXPLICIT Version DEFAULT v1,
+   responderID              ResponderID,
+   producedAt               GeneralizedTime,
+   responses                SEQUENCE OF SingleResponse,
+   responseExtensions   [1] EXPLICIT Extensions
+                               {{re-ocsp-nonce, ...,
+                                 re-ocsp-extended-revoke}} OPTIONAL }
+
+ResponderID ::= CHOICE {
+   byName   [1] Name,
+   byKey    [2] KeyHash }
+
+KeyHash ::= OCTET STRING -- SHA-1 hash of responder's public key
+                         -- (excluding the tag and length fields)
+
+SingleResponse ::= SEQUENCE {
+   certID                       CertID,
+   certStatus                   CertStatus,
+   thisUpdate                   GeneralizedTime,
+   nextUpdate           [0]     EXPLICIT GeneralizedTime OPTIONAL,
+   singleExtensions     [1]     EXPLICIT Extensions{{re-ocsp-crl |
+                                             re-ocsp-archive-cutoff |
+                                             CrlEntryExtensions, ...}
+                                             } OPTIONAL }
+
+CertStatus ::= CHOICE {
+    good                [0]     IMPLICIT NULL,
+    revoked             [1]     IMPLICIT RevokedInfo,
+    unknown             [2]     IMPLICIT UnknownInfo }
+
+RevokedInfo ::= SEQUENCE {
+    revocationTime              GeneralizedTime,
+    revocationReason    [0]     EXPLICIT CRLReason OPTIONAL }
+
+UnknownInfo ::= NULL
+
+ArchiveCutoff ::= GeneralizedTime
+
+AcceptableResponses ::= SEQUENCE OF RESPONSE.&id({ResponseSet})
+
+ServiceLocator ::= SEQUENCE {
+    issuer    Name,
+    locator   AuthorityInfoAccessSyntax }
+
+CrlID ::= SEQUENCE {
+    crlUrl               [0]     EXPLICIT IA5String OPTIONAL,
+    crlNum               [1]     EXPLICIT INTEGER OPTIONAL,
+    crlTime              [2]     EXPLICIT GeneralizedTime OPTIONAL }
+
+PreferredSignatureAlgorithms ::= SEQUENCE OF PreferredSignatureAlgorithm
+
+PreferredSignatureAlgorithm ::= SEQUENCE {
+   sigIdentifier  AlgorithmIdentifier{SIGNATURE-ALGORITHM, {...}},
+   certIdentifier AlgorithmIdentifier{PUBLIC-KEY, {...}} OPTIONAL
+}
+
+-- Certificate Extensions
+
+ext-ocsp-nocheck EXTENSION ::= { SYNTAX NULL IDENTIFIED
+                                 BY id-pkix-ocsp-nocheck }
+
+-- Request Extensions
+
+re-ocsp-nonce EXTENSION ::= { SYNTAX OCTET STRING IDENTIFIED
+                              BY id-pkix-ocsp-nonce }
+
+re-ocsp-response EXTENSION ::= { SYNTAX AcceptableResponses IDENTIFIED
+                                 BY id-pkix-ocsp-response }
+
+re-ocsp-service-locator EXTENSION ::= { SYNTAX ServiceLocator
+                                        IDENTIFIED BY
+                                        id-pkix-ocsp-service-locator }
+
+re-ocsp-preferred-signature-algorithms EXTENSION ::= {
+   SYNTAX PreferredSignatureAlgorithms
+   IDENTIFIED BY id-pkix-ocsp-pref-sig-algs  }
+
+-- Response Extensions
+
+re-ocsp-crl EXTENSION ::= { SYNTAX CrlID IDENTIFIED BY
+                                id-pkix-ocsp-crl }
+
+re-ocsp-archive-cutoff EXTENSION ::= { SYNTAX ArchiveCutoff
+                                       IDENTIFIED BY
+                                       id-pkix-ocsp-archive-cutoff }
+
+re-ocsp-extended-revoke EXTENSION ::= { SYNTAX NULL IDENTIFIED BY
+                                        id-pkix-ocsp-extended-revoke }
+
+-- Object Identifiers
+
+id-kp-OCSPSigning            OBJECT IDENTIFIER ::= { id-kp 9 }
+id-pkix-ocsp                 OBJECT IDENTIFIER ::= id-ad-ocsp
+id-pkix-ocsp-basic           OBJECT IDENTIFIER ::= { id-pkix-ocsp 1 }
+id-pkix-ocsp-nonce           OBJECT IDENTIFIER ::= { id-pkix-ocsp 2 }
+id-pkix-ocsp-crl             OBJECT IDENTIFIER ::= { id-pkix-ocsp 3 }
+id-pkix-ocsp-response        OBJECT IDENTIFIER ::= { id-pkix-ocsp 4 }
+id-pkix-ocsp-nocheck         OBJECT IDENTIFIER ::= { id-pkix-ocsp 5 }
+id-pkix-ocsp-archive-cutoff  OBJECT IDENTIFIER ::= { id-pkix-ocsp 6 }
+id-pkix-ocsp-service-locator OBJECT IDENTIFIER ::= { id-pkix-ocsp 7 }
+id-pkix-ocsp-pref-sig-algs   OBJECT IDENTIFIER ::= { id-pkix-ocsp 8 }
+id-pkix-ocsp-extended-revoke OBJECT IDENTIFIER ::= { id-pkix-ocsp 9 }
+
+END
index 9a18afc..e514e0e 100644 (file)
@@ -1,5 +1,3 @@
-PREFIX=/usr/local
-
 all:
 
 clean:
@@ -12,8 +10,8 @@ install:
        #
        # This tool will complain about DER errors -- but continue.
        #
-       [ -r hexio/derdump.py ] && install -m 0755 hexio/derdump.py "$(PREFIX)/bin/derdump"
+       [ -r hexio/derdump.py ] && install -m 0755 hexio/derdump.py "$(DESTDIR)$(PREFIX)/bin/derdump"
 
 uninstall:
-       rm -f "$(PREFIX)/bin/derdump"
+       rm -f "$(DESTDIR)$(PREFIX)/bin/derdump"