├── .gitignore └── src ├── main ├── java │ └── org │ │ └── certificateservices │ │ └── custom │ │ └── c2x │ │ ├── common │ │ ├── CertStore.java │ │ ├── BadArgumentException.java │ │ ├── InternalErrorException.java │ │ ├── MapCertStore.java │ │ ├── crypto │ │ │ ├── CryptoManagerParams.java │ │ │ ├── AlgorithmIndicator.java │ │ │ ├── InvalidSignatureException.java │ │ │ ├── Mac1.java │ │ │ ├── DefaultCryptoManagerParams.java │ │ │ └── BadCredentialsException.java │ │ ├── InvalidMessageException.java │ │ ├── Encodable.java │ │ ├── validator │ │ │ ├── TimeValidator.java │ │ │ ├── RegionValidator.java │ │ │ ├── InvalidCRLException.java │ │ │ ├── InvalidCTLException.java │ │ │ ├── CertificateRevokedException.java │ │ │ └── InvalidCertificateException.java │ │ └── CountryCode.java │ │ ├── asn1 │ │ └── coer │ │ │ ├── COEREnumerationType.java │ │ │ ├── COEREncodable.java │ │ │ ├── COERChoiceEnumeration.java │ │ │ └── COERNull.java │ │ ├── etsits103097 │ │ └── v131 │ │ │ ├── validator │ │ │ └── CRLServicePermissions.java │ │ │ ├── datastructs │ │ │ └── cert │ │ │ │ └── SingleEtsiTs103097Certificate.java │ │ │ └── AvailableITSAID.java │ │ ├── ieee1609dot2 │ │ ├── datastructs │ │ │ ├── basic │ │ │ │ ├── UnknownLongitude.java │ │ │ │ ├── UnknownLatitude.java │ │ │ │ ├── IValue.java │ │ │ │ ├── Uint3.java │ │ │ │ ├── Uint8.java │ │ │ │ ├── CrlSeries.java │ │ │ │ ├── Uint16.java │ │ │ │ ├── Uint32.java │ │ │ │ ├── Elevation.java │ │ │ │ ├── Opaque.java │ │ │ │ ├── CountryOnly.java │ │ │ │ ├── SymmAlgorithm.java │ │ │ │ ├── Uint64.java │ │ │ │ ├── Hostname.java │ │ │ │ ├── EccCurvePoint.java │ │ │ │ ├── KnownLongitude.java │ │ │ │ ├── KnownLatitude.java │ │ │ │ ├── HashAlgorithm.java │ │ │ │ ├── Latitude.java │ │ │ │ ├── LaId.java │ │ │ │ ├── Longitude.java │ │ │ │ ├── LinkageSeed.java │ │ │ │ ├── LinkageValue.java │ │ │ │ ├── SequenceOfPsid.java │ │ │ │ ├── SequenceOfUint8.java │ │ │ │ ├── SequenceOfUint16.java │ │ │ │ ├── Psid.java │ │ │ │ └── SequenceOfPsidSsp.java │ │ │ ├── cert │ │ │ │ └── CertificateType.java │ │ │ ├── crl │ │ │ │ ├── ssp │ │ │ │ │ └── CracaType.java │ │ │ │ └── secenv │ │ │ │ │ └── CrlPsid.java │ │ │ ├── p2p │ │ │ │ └── CaCertP2pPDU.java │ │ │ └── enc │ │ │ │ └── PreSharedKeyRecipientInfo.java │ │ ├── validator │ │ │ ├── BaseRegionValidator.java │ │ │ └── EmptyDefaultSSPLookup.java │ │ └── generator │ │ │ ├── recipient │ │ │ ├── BasePKRecipient.java │ │ │ └── Recipient.java │ │ │ └── receiver │ │ │ └── SignedDataReciever.java │ │ └── etsits102941 │ │ └── v131 │ │ └── datastructs │ │ ├── basetypes │ │ ├── Version.java │ │ └── CertificateFormat.java │ │ ├── trustlist │ │ ├── CrlEntry.java │ │ ├── FullCtl.java │ │ └── DeltaCtl.java │ │ └── enrollment │ │ └── EnrollmentResponseCode.java ├── resources │ ├── IEEE-2015 │ │ ├── IEEE1609CertificateRevocationListServiceSpecificPermissions.asn │ │ ├── IEEE1609dot2-peer2peer.asn │ │ └── IEEE1609CertificateRevocationListSecureEnvelope.asn │ ├── ETSI-2017 │ │ └── EtsiTs102941TypesCaManagement.asn │ └── IEEE-2017 │ │ ├── IEEE1609CertificateRevocationListServiceSpecificPermissions.asn │ │ ├── IEEE1609dot2-peer2peer.asn │ │ └── IEEE1609CertificateRevocationListSecureEnvelope.asn └── assembly │ ├── assembly-src.xml │ └── assembly-bin.xml └── test └── groovy └── org └── certificateservices └── custom └── c2x ├── common ├── crypto │ ├── AlgorithmSpec.groovy │ └── DefaultCryptoManagerParamsSpec.groovy └── CountryCodeSpec.groovy ├── etsits102941 └── v131 │ ├── datastructs │ ├── basetypes │ │ ├── VersionSpec.groovy │ │ └── CertificateFormatSpec.groovy │ ├── trustlist │ │ ├── UrlSpec.groovy │ │ ├── DcDeleteSpec.groovy │ │ └── CrlEntrySpec.groovy │ ├── enrollment │ │ └── EnrollmentResponseCodeSpec.groovy │ └── authorizationvalidation │ │ └── AuthorizationValidationResponseCodeSpec.groovy │ ├── MessageParsingExceptionSpec.groovy │ ├── MessageProcessingExceptionSpec.groovy │ ├── SignatureVerificationExceptionSpec.groovy │ ├── DecryptionFailedExceptionSpec.groovy │ └── generator │ └── ETSITS102941SecureDataGeneratorSpec.groovy ├── ieee1609dot2 ├── datastructs │ └── basic │ │ ├── OpaqueSpec.groovy │ │ ├── HostnameSpec.groovy │ │ ├── PsidSpec.groovy │ │ ├── SymmAlgorithmSpec.groovy │ │ ├── IValueSpec.groovy │ │ ├── CrlSeriesSpec.groovy │ │ ├── CountryOnlySpec.groovy │ │ ├── LaIdSpec.groovy │ │ ├── BitmapSspSpec.groovy │ │ ├── LinkageValueSpec.groovy │ │ ├── HashAlgorithmSpec.groovy │ │ └── LinkageSeedSpec.groovy ├── validator │ └── EmptyDefaultSSPLookupSpec.groovy └── generator │ └── DecryptResultSpec.groovy └── asn1 └── coer ├── COERUTF8StringSpec.groovy ├── COERNullSpec.groovy ├── TestCOEREnumeration.groovy └── COERIA5StringSpec.groovy /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | Untitled.a1sproj 3 | TODO.txt 4 | c2c-common.iml 5 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/common/CertStore.java: -------------------------------------------------------------------------------- 1 | package org.certificateservices.custom.c2x.common; 2 | 3 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.HashedId8; 4 | 5 | 6 | /** 7 | * Interface defining a Certificate Store used to be a container of certificates. 8 | * 9 | * @author Philip Vendil 2020-04-13 10 | */ 11 | public interface CertStore { 12 | 13 | /** 14 | * Main method to fetch a certificate from the store using the hashedId. 15 | * @param hashedId the hasdedId8 value of the certificate. 16 | * @return the related certificate or null if not found. 17 | */ 18 | Certificate get(HashedId8 hashedId); 19 | } 20 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/common/crypto/AlgorithmSpec.groovy: -------------------------------------------------------------------------------- 1 | package org.certificateservices.custom.c2x.common.crypto 2 | 3 | import spock.lang.Specification 4 | import spock.lang.Unroll 5 | 6 | // TODO 7 | class AlgorithmSpec extends Specification { 8 | 9 | @Unroll 10 | def "Verify that expected field size is return for signature #signature"(){ 11 | expect: 12 | signature.fieldSize == expectedFieldSize 13 | where: 14 | signature | expectedFieldSize 15 | Algorithm.Signature.ecdsaNistP256 | 32 16 | Algorithm.Signature.ecdsaBrainpoolP256r1 | 32 17 | Algorithm.Signature.ecdsaBrainpoolP384r1 | 48 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/IEEE-2015/IEEE1609CertificateRevocationListServiceSpecificPermissions.asn: -------------------------------------------------------------------------------- 1 | IEEE1609dot2CrlSsp {iso(1) identified-organization(3) ieee(111) 2 | standards-association-numbered-series-standards(2) wave-stds(1609) 3 | dot2(2) crl(3) service-specific-permissions (3)} 4 | 5 | DEFINITIONS AUTOMATIC TAGS ::= BEGIN 6 | 7 | EXPORTS ALL; 8 | 9 | IMPORTS 10 | CrlSeries, 11 | Uint8 12 | FROM IEEE1609dot2BaseTypes {iso(1) identified-organization(3) ieee(111) 13 | standards-association-numbered-series-standards(2) wave-stds(1609) 14 | dot2(2) base(1) base-types(2)} 15 | ; 16 | 17 | 18 | CrlSsp::= SEQUENCE { 19 | version Uint8(1), 20 | associatedCraca CracaType, 21 | crls PermissibleCrls, 22 | ... 23 | } 24 | 25 | CracaType ::= ENUMERATED {isCraca, issuerIsCraca} 26 | 27 | PermissibleCrls ::= SEQUENCE OF CrlSeries 28 | 29 | END -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/common/BadArgumentException.java: -------------------------------------------------------------------------------- 1 | package org.certificateservices.custom.c2x.common; 2 | 3 | /** 4 | * Class indicating a method was called with bad arguments. 5 | * 6 | * @author Philip 2020-03-09 7 | */ 8 | public class BadArgumentException extends Exception{ 9 | 10 | /** 11 | * Class indicating a method was called with bad arguments. 12 | * @param message descriptive error message of the error. 13 | */ 14 | public BadArgumentException(String message) { 15 | super(message); 16 | } 17 | 18 | /** 19 | * Class indicating a method was called with bad arguments. 20 | * 21 | * @param message descriptive error message of the error. 22 | * @param cause cause of the exception 23 | */ 24 | public BadArgumentException(String message, Throwable cause) { 25 | super(message, cause); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/resources/ETSI-2017/EtsiTs102941TypesCaManagement.asn: -------------------------------------------------------------------------------- 1 | EtsiTs102941TypesCaManagement 2 | { itu-t(0) identified-organization(4) etsi(0) itsDomain(5) wg5(5) ts(102941) caManagement(8) version2(2)} 3 | 4 | DEFINITIONS AUTOMATIC TAGS ::= 5 | BEGIN 6 | 7 | IMPORTS 8 | 9 | EtsiTs103097Certificate, EtsiTs103097Data-Signed 10 | FROM 11 | EtsiTs103097Module 12 | {itu-t(0) identified-organization(4) etsi(0) itsDomain(5) wg5(5) ts(103097) securedMessageV1(0)} 13 | 14 | PublicKeys, CertificateSubjectAttributes 15 | FROM EtsiTs102941BaseTypes 16 | { itu-t(0) identified-organization(4) etsi(0) itsDomain(5) wg5(5) ts(102941) baseTypes(3) version2(2)} 17 | 18 | ; 19 | 20 | /************ 21 | -- CA certificate request 22 | ************/ 23 | 24 | CaCertificateRequest ::= SEQUENCE { 25 | publicKeys PublicKeys, 26 | requestedSubjectAttributes CertificateSubjectAttributes, 27 | ... 28 | } 29 | 30 | END -------------------------------------------------------------------------------- /src/main/resources/IEEE-2017/IEEE1609CertificateRevocationListServiceSpecificPermissions.asn: -------------------------------------------------------------------------------- 1 | IEEE1609dot2CrlSsp {iso(1) identified-organization(3) ieee(111) 2 | standards-association-numbered-series-standards(2) wave-stds(1609) 3 | dot2(2) crl(3) service-specific-permissions (3) major-version-2(2)} 4 | 5 | DEFINITIONS AUTOMATIC TAGS ::= BEGIN 6 | 7 | EXPORTS ALL; 8 | 9 | IMPORTS 10 | CrlSeries, 11 | Uint8 12 | FROM IEEE1609dot2BaseTypes {iso(1) identified-organization(3) ieee(111) 13 | standards-association-numbered-series-standards(2) wave-stds(1609) 14 | dot2(2) base(1) base-types(2) major-version-2 (2)} 15 | ; 16 | 17 | 18 | CrlSsp::= SEQUENCE { 19 | version Uint8(1), 20 | associatedCraca CracaType, 21 | crls PermissibleCrls, 22 | ... 23 | } 24 | 25 | CracaType ::= ENUMERATED {isCraca, issuerIsCraca} 26 | 27 | PermissibleCrls ::= SEQUENCE OF CrlSeries 28 | 29 | END -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/common/InternalErrorException.java: -------------------------------------------------------------------------------- 1 | package org.certificateservices.custom.c2x.common; 2 | 3 | /** 4 | * Class indicating and internal error in application, due to configuration other problems 5 | * 6 | * @author Philip 2019-06-18 7 | */ 8 | public class InternalErrorException extends Exception{ 9 | 10 | /** 11 | * Class indicating and internal error in application, due to configuration other problems. 12 | * @param message descriptive error message of the error. 13 | */ 14 | public InternalErrorException(String message) { 15 | super(message); 16 | } 17 | 18 | /** 19 | * Class indicating and internal error in application, due to configuration other problems. 20 | * 21 | * @param message descriptive error message of the error. 22 | * @param cause cause of the exception 23 | */ 24 | public InternalErrorException(String message, Throwable cause) { 25 | super(message, cause); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/common/MapCertStore.java: -------------------------------------------------------------------------------- 1 | package org.certificateservices.custom.c2x.common; 2 | 3 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.HashedId8; 4 | 5 | import java.util.Map; 6 | 7 | /** 8 | * Implementation of CertStore with an underlying Map of HashedId8 to Certificate. 9 | * 10 | * @author Philip Vendil 2020-04-24 11 | */ 12 | public class MapCertStore implements CertStore { 13 | 14 | private Map map; 15 | 16 | 17 | /** 18 | * Default Constructor. 19 | * @param map the underlying map of certificates. 20 | */ 21 | public MapCertStore(Map map){ 22 | this.map = map; 23 | } 24 | 25 | /** 26 | * Main method to fetch a certificate from the store using the hashedId. 27 | * 28 | * @param hashedId the hasdedId8 value of the certificate. 29 | * @return the related certificate or null if not found. 30 | */ 31 | @Override 32 | public Certificate get(HashedId8 hashedId) { 33 | return map.get(hashedId); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/common/crypto/CryptoManagerParams.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.common.crypto; 14 | 15 | /** 16 | * Base interface for CryptoManagerParams used to initialize a CryptoManager library. 17 | * 18 | * @author Philip Vendil, p.vendil@cgi.com 19 | * 20 | */ 21 | public interface CryptoManagerParams { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/common/crypto/AlgorithmIndicator.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.common.crypto; 14 | 15 | /** 16 | * Interface that all cryptograpic key algorithms enumerations should implement in order 17 | * to be used with the CryptoManager 18 | * 19 | * @author Philip Vendil, p.vendil@cgi.com 20 | * 21 | */ 22 | public interface AlgorithmIndicator { 23 | 24 | Algorithm getAlgorithm(); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/resources/IEEE-2017/IEEE1609dot2-peer2peer.asn: -------------------------------------------------------------------------------- 1 | IEEE1609dot2-Peer2Peer {iso(1) identified-organization(3) ieee(111) 2 | standards-association-numbered-series-standards(2) wave-stds(1609) 3 | dot2(2) management (2) peer-to-peer (1) major-version-2(2)} 4 | 5 | --********************************************************************** 6 | -- 7 | -- Data types for Peer-to-peer distribution of IEEE P1609.2 support data 8 | -- 9 | -- Associated with a two-byte PSID to be assigned. 10 | -- When broadcast over WSMP, to be encoded with OER. 11 | -- 12 | --********************************************************************** 13 | 14 | DEFINITIONS AUTOMATIC TAGS ::= BEGIN 15 | 16 | EXPORTS ALL; 17 | 18 | IMPORTS 19 | Uint8 20 | FROM IEEE1609dot2BaseTypes {iso(1) identified-organization(3) ieee(111) 21 | standards-association-numbered-series-standards(2) wave-stds(1609) 22 | dot2(2) base(1) base-types(2) major-version-2 (2)} 23 | 24 | 25 | Certificate 26 | FROM IEEE1609dot2 {iso(1) identified-organization(3) ieee(111) 27 | standards-association-numbered-series-standards(2) wave-stds(1609) 28 | dot2(2) base(1) schema(1) major-version-2 (2)} 29 | ; 30 | 31 | Ieee1609dot2Peer2PeerPDU ::= SEQUENCE { 32 | version Uint8(1), 33 | content CHOICE { 34 | caCerts CaCertP2pPDU, 35 | ... 36 | } 37 | } 38 | 39 | CaCertP2pPDU::= SEQUENCE OF Certificate 40 | 41 | END -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/asn1/coer/COEREnumerationType.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.asn1.coer; 14 | 15 | 16 | /** 17 | * Interface that all COER Enumeration should implement. 18 | *

19 | * 20 | * @author Philip Vendil, p.vendil@cgi.com 21 | * 22 | */ 23 | public interface COEREnumerationType { 24 | 25 | /** 26 | * 27 | * @return the enumeration ordinal which gives the tag number. 28 | */ 29 | public int ordinal(); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/asn1/coer/COEREncodable.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.asn1.coer; 14 | 15 | import java.io.Serializable; 16 | 17 | import org.certificateservices.custom.c2x.common.Encodable; 18 | 19 | /** 20 | * Base interface all COER Encodable structures must implement. 21 | * 22 | * @author Philip Vendil, p.vendil@cgi.com 23 | * 24 | */ 25 | public interface COEREncodable extends Encodable, Serializable{ 26 | 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/resources/IEEE-2015/IEEE1609dot2-peer2peer.asn: -------------------------------------------------------------------------------- 1 | IEEE1609dot2-Peer2Peer {iso(1) identified-organization(3) ieee(111) 2 | standards-association-numbered-series-standards(2) wave-stds(1609) 3 | dot2(2) management (2) peer-to-peer (1)} 4 | 5 | --********************************************************************** 6 | -- 7 | -- Data types for Peer-to-peer distribution of IEEE P1609.2 support data 8 | -- 9 | -- Associated with a two-byte PSID to be assigned. 10 | -- When broadcast over WSMP, to be encoded with OER. 11 | -- 12 | --********************************************************************** 13 | 14 | DEFINITIONS AUTOMATIC TAGS ::= BEGIN 15 | 16 | EXPORTS ALL; 17 | 18 | IMPORTS 19 | Uint8 20 | FROM IEEE1609dot2BaseTypes {iso(1) identified-organization(3) ieee(111) 21 | standards-association-numbered-series-standards(2) wave-stds(1609) 22 | dot2(2) base(1) base-types(2)} 23 | 24 | 25 | Certificate 26 | FROM IEEE1609dot2 {iso(1) identified-organization(3) ieee(111) 27 | standards-association-numbered-series-standards(2) wave-stds(1609) 28 | dot2(2) base(1) schema(1)} 29 | ; 30 | 31 | Ieee1609dot2Peer2PeerPDU ::= SEQUENCE { 32 | version Uint8(1), 33 | content CHOICE { 34 | caCerts CaCertP2pPDU, 35 | crl CrlP2pPDU, 36 | ... 37 | } 38 | } 39 | 40 | CaCertP2pPDU::= SEQUENCE OF Certificate 41 | 42 | CrlP2pPDU ::= NULL 43 | 44 | END -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/etsits103097/v131/validator/CRLServicePermissions.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.etsits103097.v131.validator; 14 | 15 | /** 16 | * Class containing all CRLService related constants used 17 | * to check permissions in certificate. 18 | * 19 | * @author Philip Vendil, p.vendil@cgi.com 20 | */ 21 | public class CRLServicePermissions { 22 | 23 | /** 24 | * Current version of CRLService SSP Data. 25 | */ 26 | public static final byte VERSION_1 = 1; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/common/crypto/DefaultCryptoManagerParamsSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.common.crypto 14 | 15 | import org.certificateservices.custom.c2x.common.crypto.DefaultCryptoManagerParams; 16 | 17 | import spock.lang.Specification; 18 | 19 | /** 20 | * 21 | * @author Philip Vendil, p.vendil@cgi.com 22 | * 23 | */ 24 | class DefaultCryptoManagerParamsSpec extends Specification { 25 | 26 | def "Verify that constructor and getters and setters work"(){ 27 | expect: 28 | new DefaultCryptoManagerParams("BC").getProvider() == "BC" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/UnknownLongitude.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | 16 | import java.io.IOException; 17 | 18 | /** 19 | * Unknown longitude with encoded value of 1800000001. 20 | * 21 | * @author Philip Vendil, p.vendil@cgi.com 22 | * 23 | */ 24 | public class UnknownLongitude extends OneEightyDegreeInt { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | /** 29 | * Constructor used for encoding and decoding. 30 | */ 31 | public UnknownLongitude()throws IOException { 32 | super(UNKNOWN); 33 | } 34 | 35 | 36 | 37 | @Override 38 | public String toString() { 39 | return "UnknownLongitude [UNKNOWN]"; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/UnknownLatitude.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | 16 | import java.io.IOException; 17 | 18 | /** 19 | * Unknown latitude with encoded value of 900000001 20 | * 21 | * @author Philip Vendil, p.vendil@cgi.com 22 | * 23 | */ 24 | public class UnknownLatitude extends NinetyDegreeInt { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | /** 29 | * Constructor used for encoding and decoding. 30 | */ 31 | public UnknownLatitude() throws IOException { 32 | super(UNKNOWN); 33 | } 34 | 35 | 36 | 37 | @Override 38 | public String toString() { 39 | return "UnknownLatitude [UNKNOWN]"; 40 | } 41 | 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/IValue.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | 16 | import java.io.IOException; 17 | 18 | /** 19 | * 16 bit Integer 20 | * 21 | * @author Philip Vendil, p.vendil@cgi.com 22 | * 23 | */ 24 | public class IValue extends Uint16 { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | /** 29 | * Constructor used when decoding 30 | */ 31 | public IValue(){ 32 | super(); 33 | } 34 | 35 | /** 36 | * Constructor used when encoding 37 | */ 38 | public IValue(int ivalue) throws IOException { 39 | super(ivalue); 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "IValue [" + getValueAsLong() + "]"; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/etsits102941/v131/datastructs/basetypes/VersionSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.etsits102941.v131.datastructs.basetypes 14 | 15 | import spock.lang.Specification 16 | import spock.lang.Unroll 17 | 18 | /** 19 | * Unit tests for Version 20 | * 21 | * @author Philip Vendil, p.vendil@cgi.com 22 | */ 23 | class VersionSpec extends Specification { 24 | 25 | @Unroll 26 | def "Verify that correct value #expectedInt is set for #name"(){ 27 | expect: 28 | value.valueAsLong == expectedInt 29 | value.minValue == null 30 | value.maxValue == null 31 | where: 32 | name | value | expectedInt 33 | "v1" | Version.V1 | 1 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/cert/CertificateType.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.cert; 14 | 15 | import org.certificateservices.custom.c2x.asn1.coer.COEREnumerationType; 16 | 17 | /** 18 | * This enumerated type indicates whether a certificate is explicit or implicit. 19 | *

20 | * Critical information fields:If present, this is a critical information field as defined in 5.2.5. An 21 | * implementation that does not recognize the indicated CHOICE for this type when verifying a signed SPDU 22 | * shall indicate that the signed SPDU is invalid. 23 | *

24 | * 25 | * @author Philip Vendil, p.vendil@cgi.com 26 | * 27 | */ 28 | public enum CertificateType implements COEREnumerationType { 29 | explicit, 30 | implicit; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/Uint3.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | import org.certificateservices.custom.c2x.asn1.coer.COERInteger; 16 | 17 | import java.io.IOException; 18 | 19 | /** 20 | * Base type defining integer between 0 and 7 (0x07) 21 | * 22 | * @author Philip Vendil, p.vendil@cgi.com 23 | * 24 | */ 25 | public class Uint3 extends COERInteger { 26 | 27 | private static final long serialVersionUID = 1L; 28 | 29 | /** 30 | * Constructor used when decoding 31 | */ 32 | public Uint3(){ 33 | super(0,7); 34 | } 35 | 36 | /** 37 | * Constructor used when encoding 38 | */ 39 | public Uint3(int value) { 40 | super(value,0,7); 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return "Uint3 [" + value + "]"; 46 | } 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/Uint8.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | import org.certificateservices.custom.c2x.asn1.coer.COERInteger; 16 | 17 | import java.io.IOException; 18 | 19 | /** 20 | * Base type defining integer between 0 and 255 (0xff) 21 | * 22 | * @author Philip Vendil, p.vendil@cgi.com 23 | * 24 | */ 25 | public class Uint8 extends COERInteger { 26 | 27 | private static final long serialVersionUID = 1L; 28 | 29 | /** 30 | * Constructor used when decoding 31 | */ 32 | public Uint8(){ 33 | super(0,255); 34 | } 35 | 36 | /** 37 | * Constructor used when encoding 38 | */ 39 | public Uint8(int value) { 40 | super(value,0,255); 41 | } 42 | 43 | 44 | @Override 45 | public String toString() { 46 | return "Uint8 [" + value + "]"; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/CrlSeries.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | 16 | import java.io.IOException; 17 | 18 | /** 19 | * This integer identifies a series of CRLs issued under the authority of a particular CRACA. 20 | * 21 | * @author Philip Vendil, p.vendil@cgi.com 22 | * 23 | */ 24 | public class CrlSeries extends Uint16 { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | /** 29 | * Constructor used when decoding 30 | */ 31 | public CrlSeries(){ 32 | super(); 33 | } 34 | 35 | /** 36 | * Constructor used when encoding 37 | */ 38 | public CrlSeries(int crlSeries) throws IOException { 39 | super(crlSeries); 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "CrlSeries [" + getValueAsLong() + "]"; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/Uint16.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | import org.certificateservices.custom.c2x.asn1.coer.COERInteger; 16 | 17 | import java.io.IOException; 18 | 19 | /** 20 | * Base type defining integer between 0 and 65535 (0xff ff) 21 | * 22 | * @author Philip Vendil, p.vendil@cgi.com 23 | * 24 | */ 25 | public class Uint16 extends COERInteger { 26 | 27 | private static final long serialVersionUID = 1L; 28 | 29 | /** 30 | * Constructor used when decoding 31 | */ 32 | public Uint16(){ 33 | super(0,65535); 34 | } 35 | 36 | /** 37 | * Constructor used when encoding 38 | */ 39 | public Uint16(int value) { 40 | super(value,0,65535); 41 | } 42 | 43 | 44 | @Override 45 | public String toString() { 46 | return "Uint16 [" + value + "]"; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/common/crypto/InvalidSignatureException.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.common.crypto; 14 | 15 | /** 16 | * Exception thrown by CryptoManager if a signature cannot be verified. 17 | * 18 | * @author Philip Vendil 19 | * 20 | */ 21 | public class InvalidSignatureException extends Exception { 22 | 23 | private static final long serialVersionUID = 1L; 24 | 25 | /** 26 | * Exception thrown by CryptoManager if a signature cannot be verified. 27 | * 28 | * @param message 29 | * @param cause 30 | */ 31 | public InvalidSignatureException(String message, Throwable cause) { 32 | super(message, cause); 33 | } 34 | 35 | /** 36 | * Exception thrown by CryptoManager if a signature cannot be verified. 37 | * 38 | * @param message 39 | */ 40 | public InvalidSignatureException(String message) { 41 | super(message); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/common/crypto/Mac1.java: -------------------------------------------------------------------------------- 1 | package org.certificateservices.custom.c2x.common.crypto; 2 | 3 | import org.bouncycastle.crypto.CipherParameters; 4 | import org.bouncycastle.crypto.DataLengthException; 5 | import org.bouncycastle.crypto.Digest; 6 | import org.bouncycastle.crypto.Mac; 7 | import org.bouncycastle.crypto.macs.HMac; 8 | import org.certificateservices.custom.c2x.common.BadArgumentException; 9 | 10 | public class Mac1 implements Mac{ 11 | 12 | Digest digest; 13 | HMac hMac; 14 | int tBytes; 15 | 16 | public Mac1(Digest digest, int tBits) throws BadArgumentException { 17 | if(tBits % 8 != 0){ 18 | throw new BadArgumentException("Illegal tBits argument, must be a multiple of 8."); 19 | } 20 | tBytes = tBits/8; 21 | hMac = new HMac(digest); 22 | } 23 | 24 | @Override 25 | public void init(CipherParameters params) { 26 | hMac.init(params); 27 | 28 | } 29 | 30 | @Override 31 | public String getAlgorithmName() { 32 | return digest.getAlgorithmName() + "/MAC1"; 33 | } 34 | 35 | @Override 36 | public int getMacSize() { 37 | return tBytes; 38 | } 39 | 40 | @Override 41 | public void update(byte in) throws IllegalStateException { 42 | hMac.update(in); 43 | } 44 | 45 | @Override 46 | public void update(byte[] in, int inOff, int len) 47 | throws DataLengthException, IllegalStateException { 48 | hMac.update(in, inOff, len); 49 | } 50 | 51 | @Override 52 | public int doFinal(byte[] out, int outOff) throws DataLengthException, 53 | IllegalStateException { 54 | byte[] tempOut = new byte[hMac.getMacSize()]; 55 | int retval = hMac.doFinal(tempOut, outOff); 56 | System.arraycopy(tempOut, 0, out, 0, tBytes); 57 | return retval; 58 | } 59 | 60 | @Override 61 | public void reset() { 62 | hMac.reset(); 63 | } 64 | 65 | 66 | 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/common/InvalidMessageException.java: -------------------------------------------------------------------------------- 1 | package org.certificateservices.custom.c2x.common; 2 | 3 | 4 | /** 5 | * Exception thrown if a service received invalid message data and an error response should be returned to sender. 6 | * 7 | * @author Philip Vendil 2019-09-03 8 | */ 9 | public class InvalidMessageException extends Exception { 10 | 11 | private Object errorCode; 12 | 13 | /** 14 | * Exception thrown if a service received invalid message data. 15 | * @param message a descriptive error message. 16 | * @param errorCode an error code used in message response, the type of object depends on category of request message 17 | * such as EnrollmentResponseCode if request was an Enrollment Request etc. 18 | */ 19 | public InvalidMessageException(String message, Object errorCode){ 20 | this(message,errorCode,null); 21 | } 22 | 23 | /** 24 | * Exception thrown if a service received invalid message data. 25 | * @param message a descriptive error message. 26 | * @param errorCode an error code used in message response, the type of object depends on category of request message 27 | * such as EnrollmentResponseCode if request was an Enrollment Request etc. 28 | * @param cause optional cause of this exception. 29 | */ 30 | public InvalidMessageException(String message, Object errorCode, Throwable cause){ 31 | super(message, cause); 32 | this.errorCode = errorCode; 33 | } 34 | 35 | /** 36 | * 37 | * @return an error code used in message response, the type of object depends on category of request message 38 | * such as EnrollmentResponseCode if request was an Enrollment Request etc. 39 | */ 40 | public Object getErrorCode() { 41 | return errorCode; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/etsits102941/v131/datastructs/basetypes/Version.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.etsits102941.v131.datastructs.basetypes; 14 | 15 | import org.certificateservices.custom.c2x.asn1.coer.COERInteger; 16 | 17 | /** 18 | * Class representing Version integer constants. 19 | * 20 | * @author Philip Vendil, p.vendil@cgi.com 21 | */ 22 | public class Version extends COERInteger{ 23 | 24 | public static final Version V1 = new Version(1); 25 | 26 | /** 27 | * Constructor when decoding an integer with no known min or max value. 28 | */ 29 | public Version() { 30 | super(); 31 | } 32 | 33 | /** 34 | * Constructor used when encoding integer with no known min or max value. 35 | * 36 | * @param value the integer value. 37 | */ 38 | public Version(long value) { 39 | super(value); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/assembly/assembly-src.xml: -------------------------------------------------------------------------------- 1 | 5 | src 6 | 7 | 8 | zip 9 | 10 | 11 | 12 | repository 13 | true 14 | 15 | 16 | 17 | 18 | ${project.basedir}/ 19 | / 20 | 21 | src/** 22 | pom.xml 23 | README* 24 | LICENSE* 25 | NOTICE* 26 | 27 | 28 | 29 | ${project.basedir}/src/site/markdown 30 | / 31 | 32 | README* 33 | LICENSE* 34 | NOTICE* 35 | 36 | 37 | 38 | ${project.build.directory} 39 | / 40 | 41 | c2c-common*.jar 42 | 43 | 44 | 45 | ${project.build.directory}/site 46 | docs 47 | 48 | 49 | 50 | 51 | /lib 52 | false 53 | runtime 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/Uint32.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | import org.certificateservices.custom.c2x.asn1.coer.COERInteger; 16 | 17 | import java.io.IOException; 18 | 19 | /** 20 | * Base type defining integer between 0 and 4294967295 (0xff ff ff ff) 21 | * 22 | * @author Philip Vendil, p.vendil@cgi.com 23 | * 24 | */ 25 | public class Uint32 extends COERInteger { 26 | 27 | private static final long serialVersionUID = 1L; 28 | 29 | /** 30 | * Constructor used when decoding 31 | */ 32 | public Uint32(){ 33 | super(0,4294967295L); 34 | } 35 | 36 | /** 37 | * Constructor used when encoding 38 | */ 39 | public Uint32(long value) { 40 | super(value,0,4294967295L); 41 | } 42 | 43 | 44 | @Override 45 | public String toString() { 46 | return "Uint32 [" + value + "]"; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/etsits102941/v131/datastructs/trustlist/UrlSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.etsits102941.v131.datastructs.trustlist 14 | 15 | import spock.lang.Specification 16 | 17 | /** 18 | * Unit test for Url 19 | * 20 | * @author Philip Vendil, p.vendil@cgi.com 21 | */ 22 | class UrlSpec extends Specification { 23 | 24 | def "Verify that constructor and getter"(){ 25 | expect: 26 | new Url(4,5).getLowerBound() == 4 27 | new Url(4,5).getUpperBound() == 5 28 | new Url("http://test.com").getUrl() == "http://test.com" 29 | new Url("a",1,5).getLowerBound() == 1 30 | new Url("a",1,5).getUpperBound() == 5 31 | new Url("ab",1,5).getUrl() == "ab" 32 | } 33 | 34 | 35 | def "Verify toString"(){ 36 | expect: 37 | new Url("http://test.com").toString() == "URL [http://test.com]" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/crl/ssp/CracaType.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.crl.ssp; 14 | 15 | import org.certificateservices.custom.c2x.asn1.coer.COEREnumerationType; 16 | 17 | /** 18 | * This type is used to determine the validity of the cracaId field in the CrlContents structure. 19 | * 25 | * 26 | * @author Philip Vendil, p.vendil@cgi.com 27 | * 28 | */ 29 | public enum CracaType implements COEREnumerationType { 30 | isCraca, 31 | issuerIsCraca; 32 | } 33 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/OpaqueSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic 14 | 15 | import org.certificateservices.custom.c2x.common.crypto.DefaultCryptoManagerParams; 16 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.Opaque; 17 | 18 | import spock.lang.Specification; 19 | import spock.lang.Unroll; 20 | 21 | /** 22 | * Test for Opaque 23 | * 24 | * @author Philip Vendil, p.vendil@cgi.com 25 | * 26 | */ 27 | class OpaqueSpec extends Specification { 28 | 29 | 30 | def "Verify that Opaque has no size boundraries"(){ 31 | when: 32 | def o = new Opaque() 33 | 34 | then: 35 | o.getLowerBound() == null 36 | o.getUpperBound() == null 37 | 38 | } 39 | 40 | def "Verify toString"(){ 41 | expect: 42 | new Opaque("Test".getBytes("UTF-8")).toString() == "Opaque [data=54657374]" 43 | } 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/Elevation.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | 16 | /** 17 | * Extends Elevation 18 | * 19 | * @see ElevInt 20 | * 21 | * @author Philip Vendil, p.vendil@cgi.com 22 | * 23 | */ 24 | public class Elevation extends ElevInt { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | /** 29 | * Constructor used when decoding 30 | */ 31 | public Elevation(){ 32 | super(); 33 | } 34 | 35 | /** 36 | * Constructor used when encoding 37 | * @param elevationDecimeters should be height in decimeters, between -4095 and 61439 38 | */ 39 | public Elevation(int elevationDecimeters) { 40 | super(elevationDecimeters); 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return "Elevation [" + getElevationInDecimeters() + "(" + Integer.toString(getEncodedElevation(),16)+ ")"+ "]"; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/Opaque.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | import org.bouncycastle.util.encoders.Hex; 16 | import org.certificateservices.custom.c2x.asn1.coer.COEROctetStream; 17 | 18 | /** 19 | * Base type defining opaque data, i.e. unknown byte array with no lower or upper bounds. 20 | * 21 | * @author Philip Vendil, p.vendil@cgi.com 22 | * 23 | */ 24 | public class Opaque extends COEROctetStream { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | /** 29 | * Constructor used when decoding 30 | */ 31 | public Opaque(){ 32 | super(); 33 | } 34 | 35 | /** 36 | * Constructor used when encoding 37 | */ 38 | public Opaque(byte[] data){ 39 | super(data); 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "Opaque [data=" + new String(Hex.encode(data)) + "]"; 45 | } 46 | 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/asn1/coer/COERUTF8StringSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.asn1.coer 14 | 15 | 16 | import org.bouncycastle.util.encoders.Hex; 17 | import org.certificateservices.custom.c2x.common.BaseStructSpec 18 | 19 | import spock.lang.Specification 20 | import spock.lang.Unroll; 21 | 22 | 23 | class COERUTF8StringSpec extends BaseStructSpec { 24 | 25 | 26 | 27 | def "Verify that constuctor and getter"(){ 28 | expect: 29 | new COERUTF8String(4,5).getLowerBound() == 4 30 | new COERUTF8String(4,5).getUpperBound() == 5 31 | new COERUTF8String("a").getUTF8String() == "a" 32 | new COERUTF8String("a",1,5).getLowerBound() == 1 33 | new COERUTF8String("a",1,5).getUpperBound() == 5 34 | new COERUTF8String("ab",1,5).getUTF8String() == "ab" 35 | } 36 | 37 | def "Verify toString"(){ 38 | expect: 39 | new COERUTF8String("ab").toString() == "COERUTF8String [UTF8String=ab]" 40 | } 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/ieee1609dot2/validator/EmptyDefaultSSPLookupSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.validator 14 | 15 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.Psid 16 | import spock.lang.Specification 17 | 18 | /** 19 | * Unit tests for EmptyDefaultSSPLookup. 20 | * 21 | * @author Philip Vendil, p.vendil@cgi.com 22 | */ 23 | class EmptyDefaultSSPLookupSpec extends Specification { 24 | 25 | EmptyDefaultSSPLookup lookup = new EmptyDefaultSSPLookup() 26 | 27 | def "Verify that getDefaultSSP always returns null"(){ 28 | expect: 29 | lookup.getDefaultSSP(null) == null 30 | lookup.getDefaultSSP(new Psid(123)) == null 31 | } 32 | 33 | def "Verify that getDefaultSSPRange always returns null"(){ 34 | expect: 35 | lookup.getDefaultSSPRange(null) == null 36 | lookup.getDefaultSSPRange(new Psid(123)) == null 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/etsits102941/v131/datastructs/basetypes/CertificateFormatSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.etsits102941.v131.datastructs.basetypes 14 | 15 | import spock.lang.Specification 16 | import spock.lang.Unroll 17 | 18 | import static org.certificateservices.custom.c2x.etsits102941.v131.datastructs.basetypes.CertificateFormat.TS103097C131 19 | 20 | /** 21 | * Unit tests for CertificateFormat 22 | * 23 | * @author Philip Vendil, p.vendil@cgi.com 24 | */ 25 | class CertificateFormatSpec extends Specification { 26 | 27 | @Unroll 28 | def "Verify that correct value #expectedInt is set for #name"(){ 29 | expect: 30 | value.valueAsLong == expectedInt 31 | value.minValue.toInteger() == 1 32 | value.maxValue.toInteger() == 255 33 | where: 34 | name | value | expectedInt 35 | "ts103097v131" | TS103097C131 | 1 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/etsits102941/v131/datastructs/trustlist/DcDeleteSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.etsits102941.v131.datastructs.trustlist 14 | 15 | import spock.lang.Specification 16 | 17 | /** 18 | * Unit tests for DcDelete 19 | * 20 | * @author Philip Vendil, p.vendil@cgi.com 21 | */ 22 | class DcDeleteSpec extends Specification { 23 | 24 | def "Verify that constructor and getter"(){ 25 | expect: 26 | new DcDelete(4,5).getLowerBound() == 4 27 | new DcDelete(4,5).getUpperBound() == 5 28 | new DcDelete("http://test.com").getUrl() == "http://test.com" 29 | new DcDelete("a",1,5).getLowerBound() == 1 30 | new DcDelete("a",1,5).getUpperBound() == 5 31 | new DcDelete("ab",1,5).getUrl() == "ab" 32 | } 33 | 34 | def "Verify toString"(){ 35 | expect: 36 | new DcDelete("http://test.com").toString() == "DcDelete [http://test.com]" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/CountryOnly.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | 16 | import java.io.IOException; 17 | 18 | /** 19 | * This is the integer representation of the country or area identifier as defined by the United Nations Statistics 20 | * Division in October 2013 (see normative references in Clause 2). 21 | * 22 | * @author Philip Vendil, p.vendil@cgi.com 23 | * 24 | */ 25 | public class CountryOnly extends Uint16 { 26 | 27 | private static final long serialVersionUID = 1L; 28 | 29 | /** 30 | * Constructor used when decoding 31 | */ 32 | public CountryOnly(){ 33 | super(); 34 | } 35 | 36 | /** 37 | * Constructor used when encoding 38 | */ 39 | public CountryOnly(int countryCode) { 40 | super(countryCode); 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return "CountryOnly [" + getValueAsLong() + "]"; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/crl/secenv/CrlPsid.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.crl.secenv; 14 | 15 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.Psid; 16 | 17 | import java.io.IOException; 18 | 19 | /** 20 | * This type represents the CRL PSID 21 | *

22 | * PSID = 0x24, WW: this may need to change, just a placeholder 23 | * 24 | * @author Philip Vendil, p.vendil@cgi.com 25 | * 26 | */ 27 | public class CrlPsid extends Psid { 28 | 29 | public static final int PSID = 0x24; 30 | 31 | private static final long serialVersionUID = 1L; 32 | 33 | /** 34 | * Constructor used when encoding and decoding 35 | * 36 | */ 37 | public CrlPsid() throws IOException { 38 | super(PSID); 39 | } 40 | 41 | 42 | @Override 43 | public String toString() { 44 | return "CrlPsid [" + getValue().toString() + "(" + getValue().toString(16)+ ")"+ "]"; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/resources/IEEE-2017/IEEE1609CertificateRevocationListSecureEnvelope.asn: -------------------------------------------------------------------------------- 1 | IEEE1609dot2Crl {iso(1) identified-organization(3) ieee(111) 2 | standards-association-numbered-series-standards(2) wave-stds(1609) 3 | dot2(2) crl(3) protocol(1) major-version-2(2)} 4 | 5 | DEFINITIONS AUTOMATIC TAGS ::= BEGIN 6 | 7 | EXPORTS ALL; 8 | 9 | IMPORTS 10 | 11 | Ieee1609Dot2Data 12 | FROM IEEE1609dot2 {iso(1) identified-organization(3) ieee(111) 13 | standards-association-numbered-series-standards(2) wave-stds(1609) 14 | dot2(2) base (1) schema (1) major-version-2 (2)} 15 | 16 | Opaque, 17 | Psid 18 | FROM IEEE1609dot2BaseTypes {iso(1) identified-organization(3) ieee(111) 19 | standards-association-numbered-series-standards(2) wave-stds(1609) 20 | dot2(2) base(1) base-types(2) major-version-2 (2)} 21 | 22 | CrlContents 23 | FROM IEEE1609dot2CrlBaseTypes {iso(1) identified-organization(3) ieee(111) 24 | standards-association-numbered-series-standards(2) wave-stds(1609) 25 | dot2(2) crl(3) base-types(2) major-version-2 (2)} 26 | 27 | ; 28 | 29 | CrlPsid ::= Psid(256) -- PSID = 0x100, 0p8080 30 | 31 | SecuredCrl ::= Ieee1609Dot2Data (WITH COMPONENTS {..., 32 | content (WITH COMPONENTS { 33 | signedData (WITH COMPONENTS {..., 34 | tbsData (WITH COMPONENTS { 35 | payload (WITH COMPONENTS {..., 36 | data (WITH COMPONENTS {..., 37 | content (WITH COMPONENTS { 38 | unsecuredData (CONTAINING CrlContents) 39 | }) 40 | }) 41 | }), 42 | headerInfo (WITH COMPONENTS {..., 43 | psid (CrlPsid), 44 | generationTime ABSENT, 45 | expiryTime ABSENT, 46 | generationLocation ABSENT, 47 | p2pcdLearningRequest ABSENT, 48 | missingCrlIdentifier ABSENT, 49 | encryptionKey ABSENT 50 | }) 51 | }) 52 | }) 53 | }) 54 | }) 55 | 56 | 57 | END -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/SymmAlgorithm.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | import org.certificateservices.custom.c2x.asn1.coer.COEREnumerationType; 16 | import org.certificateservices.custom.c2x.common.crypto.Algorithm; 17 | import org.certificateservices.custom.c2x.common.crypto.Algorithm.Hash; 18 | import org.certificateservices.custom.c2x.common.crypto.AlgorithmIndicator; 19 | 20 | /** 21 | * This enumerated value indicates supported symmetric algorithms. The only symmetric algorithm supported in this version of this standard is AES-CCM as specified in 5.3.8. 22 | *

23 | * 24 | * @author Philip Vendil, p.vendil@cgi.com 25 | * 26 | */ 27 | public enum SymmAlgorithm implements COEREnumerationType, AlgorithmIndicator { 28 | aes128Ccm; 29 | 30 | @Override 31 | public Algorithm getAlgorithm() { 32 | return new Algorithm(Algorithm.Symmetric.aes128Ccm, null, null, Hash.sha256); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/validator/BaseRegionValidator.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.validator; 14 | 15 | import org.certificateservices.custom.c2x.common.validator.RegionValidator; 16 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.GeographicRegion; 17 | 18 | /** 19 | * Abstract base class of region validators containing in common help methods. 20 | * 21 | * @author Philip Vendil, p.vendil@cgi.com 22 | */ 23 | public abstract class BaseRegionValidator implements RegionValidator { 24 | 25 | 26 | /** 27 | * Help method to get the GeographicRegion from a certificate 28 | * @param certificate the certificate to fetch region from 29 | * @return the region field in the certificate. 30 | */ 31 | protected GeographicRegion getRegion(org.certificateservices.custom.c2x.ieee1609dot2.datastructs.cert.Certificate certificate){ 32 | return certificate.getToBeSigned().getRegion(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/asn1/coer/COERNullSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.asn1.coer 14 | 15 | import org.bouncycastle.asn1.ASN1Boolean 16 | import org.certificateservices.custom.c2x.common.BaseStructSpec 17 | 18 | import spock.lang.Specification 19 | import spock.lang.Unroll; 20 | 21 | class COERNullSpec extends BaseStructSpec { 22 | 23 | def "Verify that COERNull with value #value returns #encoded encoded and encoded #encoded generates a #value value"(){ 24 | expect: 25 | serializeToHex(new COERNull()) == "" 26 | deserializeFromHex(new COERNull(), "") 27 | } 28 | 29 | def "Verify equals and hashcode"(){ 30 | expect: 31 | COERBoolean.TRUE != new COERNull() 32 | new COERNull() == new COERNull() 33 | COERBoolean.TRUE.hashCode() != new COERNull().hashCode() 34 | new COERNull().hashCode() == new COERNull().hashCode() 35 | } 36 | 37 | def "Verify toString"(){ 38 | expect: 39 | new COERNull().toString() == "COERNull []" 40 | } 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/common/crypto/DefaultCryptoManagerParams.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.common.crypto; 14 | 15 | 16 | /** 17 | * Configuration parameters for the DefaultCryptoManager, containing the provider to be used for underlying cryptographic operations. 18 | * 19 | * @author Philip Vendil, p.vendil@cgi.com 20 | * 21 | */ 22 | public class DefaultCryptoManagerParams implements CryptoManagerParams { 23 | 24 | private String provider; 25 | 26 | /** 27 | * Configuration parameters for the DefaultCryptoManager, containing the provider to be used for underlying cryptographic operations. 28 | * @param provider the provider to use. 29 | */ 30 | public DefaultCryptoManagerParams(String provider) { 31 | super(); 32 | this.provider = provider; 33 | } 34 | 35 | /** 36 | * 37 | * @return containing the provider to be used for underlying cryptographic operations. 38 | */ 39 | public String getProvider() { 40 | return provider; 41 | } 42 | 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/common/crypto/BadCredentialsException.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.common.crypto; 14 | 15 | /** 16 | * Exception thrown if supplied credentials to authenticate towards underlying hardward cryptographic was wrong. 17 | * 18 | * @author Philip 19 | * 20 | */ 21 | public class BadCredentialsException extends Exception { 22 | 23 | private static final long serialVersionUID = 1L; 24 | 25 | /** 26 | * Exception thrown if supplied credentials to authenticate towards underlying hardward cryptographic was wrong. 27 | */ 28 | public BadCredentialsException(String message, Throwable cause) { 29 | super(message, cause); 30 | // TODO Auto-generated constructor stub 31 | } 32 | 33 | /** 34 | * Exception thrown if supplied credentials to authenticate towards underlying hardward cryptographic was wrong. 35 | */ 36 | public BadCredentialsException(String message) { 37 | super(message); 38 | // TODO Auto-generated constructor stub 39 | } 40 | 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/etsits102941/v131/datastructs/basetypes/CertificateFormat.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.etsits102941.v131.datastructs.basetypes; 14 | 15 | import org.certificateservices.custom.c2x.asn1.coer.COERInteger; 16 | 17 | import java.io.IOException; 18 | 19 | /** 20 | * Class representing CertificateFormat integer constants. 21 | * 22 | * @author Philip Vendil, p.vendil@cgi.com 23 | */ 24 | public class CertificateFormat extends COERInteger { 25 | 26 | public static final CertificateFormat TS103097C131 = new CertificateFormat(1); 27 | 28 | 29 | /** 30 | * Constructor when decoding an integer. 31 | */ 32 | public CertificateFormat() { 33 | super(1,255); 34 | } 35 | 36 | 37 | 38 | /** 39 | * Constructor used when encoding integer 40 | * 41 | * @param value the integer value. 42 | */ 43 | public CertificateFormat(long value) throws IllegalArgumentException { 44 | super(value, 1, 255); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/etsits102941/v131/datastructs/trustlist/CrlEntrySpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.etsits102941.v131.datastructs.trustlist 14 | 15 | import org.bouncycastle.util.encoders.Hex 16 | import org.certificateservices.custom.c2x.common.BaseStructSpec 17 | 18 | /** 19 | * Unit test for CrlEntry 20 | * 21 | * @author Philip Vendil, p.vendil@cgi.com 22 | */ 23 | class CrlEntrySpec extends BaseStructSpec { 24 | 25 | byte[] digest = Hex.decode("001122334455667788") 26 | 27 | def "Verify constructor and serialization"(){ 28 | when: 29 | CrlEntry ce1 = new CrlEntry(digest) 30 | then: 31 | serializeToHex(ce1) == "1122334455667788" 32 | 33 | when: 34 | CrlEntry ce2 = deserializeFromHex(new CrlEntry(),"1122334455667788") 35 | then: 36 | ce1 == ce2 37 | } 38 | 39 | def "Verify toString()"(){ 40 | expect: 41 | new CrlEntry(digest).toString() == "CrlEntry [1122334455667788]" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/asn1/coer/COERChoiceEnumeration.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.asn1.coer; 14 | 15 | import java.io.IOException; 16 | 17 | /** 18 | * Interface that all COER Choice Enumeration should implement. 19 | *

20 | * Contains one method used to create a empty version of specific COER encodable object for 21 | * a given selection in an enum. 22 | * 23 | * @author Philip Vendil, p.vendil@cgi.com 24 | * 25 | */ 26 | public interface COERChoiceEnumeration { 27 | 28 | /** 29 | * Method that should return a NEW empty COEREncodable for a given choice in an enumeration. 30 | * Important every call should return a new object. 31 | */ 32 | COEREncodable getEmptyCOEREncodable() throws IOException; 33 | 34 | /** 35 | * 36 | * @return true if this entry is an extension or false if regular choice 37 | */ 38 | boolean isExtension(); 39 | 40 | /** 41 | * 42 | * @return the enumeration ordinal which gives the tag number. 43 | */ 44 | public int ordinal(); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/common/Encodable.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.common; 14 | 15 | import java.io.DataInputStream; 16 | import java.io.DataOutputStream; 17 | import java.io.IOException; 18 | 19 | /** 20 | * Interface for serializing structures to a byte array 21 | * 22 | * @author Philip Vendil, p.vendil@cgi.com 23 | * 24 | */ 25 | public interface Encodable { 26 | 27 | 28 | /** 29 | * Implementation should encode the data and write to the data output stream. 30 | * 31 | * @param out data output stream 32 | * @throws IOException if communication problems occurred during serialization. 33 | */ 34 | public void encode(DataOutputStream out) throws IOException; 35 | 36 | /** 37 | * Implementation should decodes the data and populate its properties. 38 | * 39 | * @param in data input stream to read from. 40 | * @throws IOException if communication problems occurred during serialization. 41 | */ 42 | public void decode(DataInputStream in) throws IOException; 43 | 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/Uint64.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | import java.io.IOException; 16 | import java.math.BigInteger; 17 | 18 | import org.certificateservices.custom.c2x.asn1.coer.COERInteger; 19 | 20 | /** 21 | * Base type defining integer between 0 and 18446744073709551615 (0xff ff ff ff ff ff ff) 22 | * 23 | * @author Philip Vendil, p.vendil@cgi.com 24 | * 25 | */ 26 | public class Uint64 extends COERInteger { 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | /** 31 | * Constructor used when decoding 32 | */ 33 | public Uint64(){ 34 | super(BigInteger.ZERO,new BigInteger("18446744073709551615")); 35 | } 36 | 37 | /** 38 | * Constructor used when encoding 39 | */ 40 | public Uint64(BigInteger value) { 41 | super(value, BigInteger.ZERO,new BigInteger("18446744073709551615")); 42 | } 43 | 44 | 45 | @Override 46 | public String toString() { 47 | return "Uint64 [" + value + "]"; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/common/CountryCodeSpec.groovy: -------------------------------------------------------------------------------- 1 | package org.certificateservices.custom.c2x.common; 2 | import spock.lang.Specification; 3 | 4 | import static org.certificateservices.custom.c2x.common.CountryCode.*; 5 | 6 | /** 7 | * Unit test for CountryCode 8 | * 9 | * @author Lu Han 2020-03-10 10 | */ 11 | class CountryCodeSpec extends Specification { 12 | 13 | def "test checkCountryCode method"(){ 14 | expect: 15 | checkCountryCode(40) // AUSTRIA 16 | checkCountryCode(56) // BELGIUM 17 | checkCountryCode(100) // BULGARIA 18 | checkCountryCode(191) // CROATIA 19 | checkCountryCode(196) // REPUBLICOFCYPRUS 20 | checkCountryCode(203) // CZECHREPUBLIC 21 | checkCountryCode(208) // DENMARK 22 | checkCountryCode(233) // ESTONIA 23 | checkCountryCode(246) // FINLAND 24 | checkCountryCode(250) // FRANCE 25 | checkCountryCode(276) // GERMANY 26 | checkCountryCode(300) // GREECE 27 | checkCountryCode(348) // HUNGARY 28 | checkCountryCode(372) // IRELAND 29 | checkCountryCode(380) // ITALY 30 | checkCountryCode(428) // LATVIA 31 | checkCountryCode(440) // LITHUANIA 32 | checkCountryCode(442) // LUXEMBOURG 33 | checkCountryCode(470) // MALTA 34 | checkCountryCode(528) // NETHERLANDS 35 | checkCountryCode(616) // POLAND 36 | checkCountryCode(620) // PORTUGAL 37 | checkCountryCode(642) // ROMANIA 38 | checkCountryCode(703) // SLOVAKIA 39 | checkCountryCode(705) // SLOVENIA 40 | checkCountryCode(724) // SPAIN 41 | checkCountryCode(752) // SWEDEN 42 | checkCountryCode(826) // UK 43 | 44 | !checkCountryCode(1) 45 | !checkCountryCode(123) 46 | } 47 | } -------------------------------------------------------------------------------- /src/main/resources/IEEE-2015/IEEE1609CertificateRevocationListSecureEnvelope.asn: -------------------------------------------------------------------------------- 1 | IEEE1609dot2Crl {iso(1) identified-organization(3) ieee(111) 2 | standards-association-numbered-series-standards(2) wave-stds(1609) 3 | dot2(2) crl(3) protocol(2)} 4 | 5 | DEFINITIONS AUTOMATIC TAGS ::= BEGIN 6 | 7 | EXPORTS ALL; 8 | 9 | IMPORTS 10 | 11 | Ieee1609Dot2Data 12 | FROM IEEE1609dot2 {iso(1) identified-organization(3) ieee(111) 13 | standards-association-numbered-series-standards(2) wave-stds(1609) 14 | dot2(2) base (1) schema (1)} 15 | 16 | Opaque, 17 | Psid 18 | FROM IEEE1609dot2BaseTypes {iso(1) identified-organization(3) ieee(111) 19 | standards-association-numbered-series-standards(2) wave-stds(1609) 20 | dot2(2) base(1) base-types(2)} 21 | 22 | CrlContents 23 | FROM IEEE1609dot2CrlBaseTypes {iso(1) identified-organization(3) ieee(111) 24 | standards-association-numbered-series-standards(2) wave-stds(1609) 25 | dot2(2) crl(3) base-types(1)} 26 | 27 | ; 28 | 29 | CrlPsid ::= Psid(256) -- PSID = 0x24, WW: this may need to change, just a placeholder 30 | 31 | SecuredCrl ::= Ieee1609Dot2Data (WITH COMPONENTS {..., 32 | content (WITH COMPONENTS { 33 | signedData (WITH COMPONENTS {..., 34 | tbsData (WITH COMPONENTS { 35 | payload (WITH COMPONENTS {..., 36 | data (WITH COMPONENTS {..., 37 | content (WITH COMPONENTS { 38 | unsecuredData (CONTAINING CrlContents) 39 | }) 40 | }) 41 | }), 42 | headerInfo (WITH COMPONENTS {..., 43 | psid (CrlPsid), 44 | generationTime ABSENT, 45 | expiryTime ABSENT, 46 | generationLocation ABSENT, 47 | p2pcdLearningRequest ABSENT, 48 | missingCrlIdentifier ABSENT, 49 | encryptionKey ABSENT 50 | }) 51 | }) 52 | }) 53 | }) 54 | }) 55 | 56 | CrlRequest ::= SEQUENCE { 57 | content Opaque, -- place-holder for now 58 | ... 59 | } 60 | 61 | END 62 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/HostnameSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic 14 | 15 | import org.certificateservices.custom.c2x.common.crypto.DefaultCryptoManagerParams; 16 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.Hostname; 17 | 18 | import spock.lang.Specification; 19 | import spock.lang.Unroll; 20 | 21 | /** 22 | * Test for Opaque 23 | * 24 | * @author Philip Vendil, p.vendil@cgi.com 25 | * 26 | */ 27 | class HostnameSpec extends Specification { 28 | 29 | 30 | def "Verify that Hostname has size boundraries 0 to 255"(){ 31 | when: 32 | def h = new Hostname() 33 | 34 | then: 35 | h.getLowerBound() == 0 36 | h.getUpperBound() == 255 37 | 38 | when: 39 | def h2 = new Hostname("test") 40 | then: 41 | h2.getLowerBound() == 0 42 | h2.getUpperBound() == 255 43 | h2.getUTF8String() == "test" 44 | 45 | } 46 | 47 | def "Verify toString"(){ 48 | expect: 49 | new Hostname("test").toString() == "Hostname [test]" 50 | } 51 | 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/Hostname.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | import java.io.IOException; 16 | import java.io.UnsupportedEncodingException; 17 | 18 | import org.certificateservices.custom.c2x.asn1.coer.COERUTF8String; 19 | 20 | /** 21 | * This is a UTF-8 string as defined in IETF RFC 3629. The contents are determined by policy. 22 | * 23 | * @author Philip Vendil, p.vendil@cgi.com 24 | * 25 | */ 26 | public class Hostname extends COERUTF8String { 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | /** 31 | * Constructor used when decoding 32 | */ 33 | public Hostname(){ 34 | super(0,255); 35 | } 36 | 37 | /** 38 | * Constructor used when encoding 39 | * 40 | * @throws IOException if UTF 8 encoding isn't supported. 41 | */ 42 | public Hostname(String hostname) throws IOException { 43 | super(hostname,0,255); 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return "Hostname [" + getUTF8String() + "]"; 49 | } 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/PsidSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic 14 | 15 | 16 | import org.certificateservices.custom.c2x.common.BaseStructSpec 17 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.Psid 18 | import spock.lang.Unroll 19 | 20 | /** 21 | * Test for Psid 22 | * 23 | * @author Philip Vendil, p.vendil@cgi.com 24 | * 25 | */ 26 | class PsidSpec extends BaseStructSpec { 27 | 28 | @Unroll 29 | def "Verify constructors"(){ 30 | when: 31 | def p1 = new Psid(255) 32 | 33 | then: 34 | p1.minValue == BigInteger.ZERO 35 | p1.maxValue == null 36 | p1.valueAsLong == 255 37 | serializeToHex(p1) == "01ff" 38 | 39 | when: 40 | def p2 = new Psid("ff") 41 | then: 42 | p2.minValue == BigInteger.ZERO 43 | p2.maxValue == null 44 | p2.valueAsLong == 255 45 | serializeToHex(p2) == "01ff" 46 | } 47 | 48 | 49 | def "Verify Psid toString"(){ 50 | expect: 51 | new Psid(1000).toString() == "Psid [1000(3e8)]" 52 | } 53 | 54 | 55 | 56 | 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/SymmAlgorithmSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic 14 | 15 | import org.certificateservices.custom.c2x.common.BaseStructSpec; 16 | import org.certificateservices.custom.c2x.common.crypto.Algorithm 17 | import org.certificateservices.custom.c2x.common.crypto.DefaultCryptoManagerParams; 18 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.Duration.DurationChoices; 19 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.SymmAlgorithm; 20 | 21 | import spock.lang.Specification; 22 | import spock.lang.Unroll; 23 | 24 | /** 25 | * Test for SymmAlgorithm 26 | * 27 | * @author Philip Vendil, p.vendil@cgi.com 28 | * 29 | */ 30 | class SymmAlgorithmSpec extends BaseStructSpec { 31 | 32 | 33 | def "Verify correct algorithms indicator is returned."(){ 34 | when: 35 | Algorithm alg = SymmAlgorithm.aes128Ccm.getAlgorithm() 36 | then: 37 | alg.getHash() == Algorithm.Hash.sha256 38 | alg.getSymmetric() == Algorithm.Symmetric.aes128Ccm 39 | alg.getSignature() == null 40 | alg.getEncryption() == null 41 | 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/asn1/coer/COERNull.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.asn1.coer; 14 | 15 | 16 | import java.io.DataInputStream; 17 | import java.io.DataOutputStream; 18 | import java.io.IOException; 19 | 20 | /** 21 | * COER encoding of a null. 22 | * 23 | * @author Philip Vendil, p.vendil@cgi.com 24 | * 25 | */ 26 | public class COERNull implements COEREncodable{ 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | 31 | /** 32 | * Constructor used when encoding/decoding a COER boolean. 33 | */ 34 | public COERNull(){ 35 | } 36 | 37 | @Override 38 | public int hashCode() { 39 | return 1; 40 | } 41 | 42 | @Override 43 | public boolean equals(Object obj) { 44 | if (this == obj) 45 | return true; 46 | if (obj == null) 47 | return false; 48 | if (getClass() != obj.getClass()) 49 | return false; 50 | return true; 51 | } 52 | 53 | 54 | @Override 55 | public void encode(DataOutputStream out) throws IOException { 56 | 57 | } 58 | 59 | @Override 60 | public void decode(DataInputStream in) throws IOException { 61 | 62 | } 63 | 64 | @Override 65 | public String toString() { 66 | return "COERNull []"; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/IValueSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic 14 | 15 | import org.bouncycastle.util.encoders.Hex; 16 | import org.certificateservices.custom.c2x.common.BaseStructSpec; 17 | import org.certificateservices.custom.c2x.common.crypto.DefaultCryptoManagerParams; 18 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.Duration.DurationChoices; 19 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.IValue; 20 | 21 | import spock.lang.Specification; 22 | import spock.lang.Unroll; 23 | 24 | /** 25 | * Test for IValue 26 | * 27 | * @author Philip Vendil, p.vendil@cgi.com 28 | * 29 | */ 30 | class IValueSpec extends BaseStructSpec { 31 | 32 | @Unroll 33 | def "Verify constructors"(){ 34 | when: 35 | def e1 = new IValue(10) 36 | 37 | then: 38 | serializeToHex(e1) == "000a" 39 | 40 | when: 41 | IValue e2 = deserializeFromHex(new IValue(), "000a") 42 | 43 | then: 44 | e2.getValueAsLong() == 10 45 | } 46 | 47 | 48 | def "Verify IValue toString"(){ 49 | expect: 50 | new IValue(1000).toString() == "IValue [1000]" 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/assembly/assembly-bin.xml: -------------------------------------------------------------------------------- 1 | 4 | bin 5 | 6 | 7 | zip 8 | 9 | 10 | 11 | repository 12 | true 13 | 14 | 15 | 16 | 17 | ${project.basedir}/src/site/markdown 18 | / 19 | 20 | README* 21 | LICENSE* 22 | NOTICE* 23 | 24 | 25 | 26 | ${project.basedir}/ 27 | / 28 | 29 | README* 30 | LICENSE* 31 | NOTICE* 32 | 33 | 34 | 35 | ${project.basedir}/src/test/resources 36 | / 37 | 38 | log4j.properties 39 | 40 | 41 | 42 | ${project.build.directory} 43 | / 44 | 45 | c2c-common*.jar 46 | 47 | 48 | 49 | ${project.build.directory}/site 50 | docs 51 | 52 | 53 | 54 | 55 | /lib 56 | false 57 | runtime 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/etsits102941/v131/datastructs/trustlist/CrlEntry.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.etsits102941.v131.datastructs.trustlist; 14 | 15 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.HashedId8; 16 | 17 | import java.io.IOException; 18 | 19 | /** 20 | * Class representing CrlEntry defined in ETSI TS 102 941 Trust List Types 21 | * 22 | * @author Philip Vendil, p.vendil@cgi.com 23 | * 24 | */ 25 | public class CrlEntry extends HashedId8 { 26 | 27 | /** 28 | * Constructor used during decoding. 29 | */ 30 | public CrlEntry() { 31 | } 32 | 33 | /** 34 | * Constructor used to create a hashedid8 value for a full hash byte array. 35 | * @param fullHashValue the fill hash value. 36 | * @throws IOException if full hash value was shorted that hash length 37 | */ 38 | public CrlEntry(byte[] fullHashValue) throws IOException { 39 | super(fullHashValue); 40 | } 41 | 42 | /** 43 | * Returns a displayable format of the content of the COEREncodable 44 | */ 45 | @Override 46 | public String toString() { 47 | return super.toString().replace("HashedId8 ","CrlEntry "); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/generator/recipient/BasePKRecipient.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.generator.recipient; 14 | 15 | import org.certificateservices.custom.c2x.common.BadArgumentException; 16 | import org.certificateservices.custom.c2x.common.crypto.AlgorithmIndicator; 17 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.enc.EncryptedDataEncryptionKey.EncryptedDataEncryptionKeyChoices; 18 | 19 | /** 20 | * Base class containing common methods for all Public Key Recipients. 21 | * 22 | * @author Philip Vendil p.vendil@cgi.com 23 | * 24 | */ 25 | public abstract class BasePKRecipient implements Recipient { 26 | 27 | 28 | protected EncryptedDataEncryptionKeyChoices getEncKeyType(AlgorithmIndicator alg) throws BadArgumentException { 29 | if(alg.getAlgorithm().getSignature() == null){ 30 | throw new BadArgumentException("Error unsupported algorithm: " + alg); 31 | } 32 | 33 | switch(alg.getAlgorithm().getSignature()){ 34 | case ecdsaNistP256: 35 | return EncryptedDataEncryptionKeyChoices.eciesNistP256; 36 | case ecdsaBrainpoolP256r1: 37 | default: 38 | return EncryptedDataEncryptionKeyChoices.eciesBrainpoolP256r1; 39 | } 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/CrlSeriesSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic 14 | 15 | import org.bouncycastle.util.encoders.Hex; 16 | import org.certificateservices.custom.c2x.common.BaseStructSpec; 17 | import org.certificateservices.custom.c2x.common.crypto.DefaultCryptoManagerParams; 18 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.Duration.DurationChoices; 19 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.CrlSeries; 20 | 21 | import spock.lang.Specification; 22 | import spock.lang.Unroll; 23 | 24 | /** 25 | * Test for CrlSeries 26 | * 27 | * @author Philip Vendil, p.vendil@cgi.com 28 | * 29 | */ 30 | class CrlSeriesSpec extends BaseStructSpec { 31 | 32 | @Unroll 33 | def "Verify constructors"(){ 34 | when: 35 | def e1 = new CrlSeries(10) 36 | 37 | then: 38 | serializeToHex(e1) == "000a" 39 | 40 | when: 41 | CrlSeries e2 = deserializeFromHex(new CrlSeries(), "000a") 42 | 43 | then: 44 | e2.getValueAsLong() == 10 45 | } 46 | 47 | 48 | def "Verify CrlSeries toString"(){ 49 | expect: 50 | new CrlSeries(1000).toString() == "CrlSeries [1000]" 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/etsits102941/v131/MessageParsingExceptionSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.etsits102941.v131 14 | 15 | import org.certificateservices.custom.c2x.ieee1609dot2.generator.receiver.Receiver 16 | import spock.lang.Specification 17 | 18 | import javax.crypto.SecretKey 19 | 20 | /** 21 | * Unit tests for MessageParsingException 22 | */ 23 | class MessageParsingExceptionSpec extends Specification { 24 | 25 | byte[] requestHash = [1,2,3] as byte[] 26 | 27 | def "Verify that constructor populates fields correctly"(){ 28 | setup: 29 | def key = Mock(SecretKey) 30 | def receiver = Mock(Receiver) 31 | def cause = new IOException() 32 | when: 33 | def e1 = new MessageParsingException("SomeMessage", key) 34 | then: 35 | e1.message == "SomeMessage" 36 | e1.getSecretKey() == key 37 | 38 | when: 39 | def e2 = new MessageParsingException("SomeMessage", cause ,key, requestHash, receiver) 40 | then: 41 | e2.message == "SomeMessage" 42 | e2.cause == cause 43 | e2.getSecretKey() == key 44 | e2.getReceiver() == receiver 45 | e2.getRequestHash() == requestHash 46 | } 47 | } -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/generator/recipient/Recipient.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.generator.recipient; 14 | 15 | import java.io.IOException; 16 | import java.security.GeneralSecurityException; 17 | 18 | import javax.crypto.SecretKey; 19 | 20 | import org.certificateservices.custom.c2x.common.BadArgumentException; 21 | import org.certificateservices.custom.c2x.common.crypto.AlgorithmIndicator; 22 | import org.certificateservices.custom.c2x.ieee1609dot2.crypto.Ieee1609Dot2CryptoManager; 23 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.enc.RecipientInfo; 24 | 25 | /** 26 | * Generic interface for a recipient used during encryption. 27 | *

28 | * A Recipient interface is used when sending data to others, Receiver is used when receiving data from others. 29 | * 30 | * @author Philip Vendil p.vendil@cgi.com 31 | * 32 | */ 33 | public interface Recipient { 34 | 35 | /** 36 | * Method to return a generated ReceiptientInfo for the given encryption key. 37 | * 38 | */ 39 | RecipientInfo toRecipientInfo(AlgorithmIndicator alg, Ieee1609Dot2CryptoManager cryptoManager,SecretKey encryptionKey) throws BadArgumentException, GeneralSecurityException, IOException; 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/EccCurvePoint.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | import org.certificateservices.custom.c2x.asn1.coer.COERChoice; 16 | import org.certificateservices.custom.c2x.asn1.coer.COERChoiceEnumeration; 17 | import org.certificateservices.custom.c2x.asn1.coer.COEREncodable; 18 | 19 | /** 20 | * Base class for both EccP256CurvePoint and EccP384CurvePoint. 21 | * 22 | * @author Philip Vendil, p.vendil@cgi.com 23 | * 24 | */ 25 | public abstract class EccCurvePoint extends COERChoice { 26 | 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | /** 31 | * Constructor used when decoding a COER Choice. 32 | * 33 | * @param choiceEnum the class of the enum that implements COERChoiceEnumeration 34 | */ 35 | public EccCurvePoint(Class choiceEnum){ 36 | super(choiceEnum); 37 | } 38 | 39 | /** 40 | * Constructor used when encoding a COER Choice. 41 | * 42 | * @param choice a enum value of an enumeration implementing COERChoiceEnumeration 43 | * @param value the related value. 44 | */ 45 | public EccCurvePoint(COERChoiceEnumeration choice, COEREncodable value){ 46 | super(choice,value); 47 | } 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/etsits102941/v131/datastructs/enrollment/EnrollmentResponseCodeSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.etsits102941.v131.datastructs.enrollment 14 | 15 | import spock.lang.Specification 16 | import spock.lang.Unroll 17 | 18 | import static EnrollmentResponseCode.* 19 | 20 | /** 21 | * Unit tests for EnrollmentResponseCode. 22 | * 23 | * @author Philip Vendil, p.vendil@cgi.com 24 | */ 25 | class EnrollmentResponseCodeSpec extends Specification { 26 | 27 | @Unroll 28 | def "Verify that #value have the following ordinal #ordinal"(){ 29 | expect: 30 | value.ordinal() == ordinal 31 | 32 | where: 33 | ordinal | value 34 | 0 | ok 35 | 1 | cantparse 36 | 2 | badcontenttype 37 | 3 | imnottherecipient 38 | 4 | unknownencryptionalgorithm 39 | 5 | decryptionfailed 40 | 6 | unknownits 41 | 7 | invalidsignature 42 | 8 | invalidencryptionkey 43 | 9 | baditsstatus 44 | 10 | incompleterequest 45 | 11 | deniedpermissions 46 | 12 | invalidkeys 47 | 13 | deniedrequest 48 | } 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/CountryOnlySpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic 14 | 15 | import org.bouncycastle.util.encoders.Hex; 16 | import org.certificateservices.custom.c2x.common.BaseStructSpec; 17 | import org.certificateservices.custom.c2x.common.crypto.DefaultCryptoManagerParams; 18 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.Duration.DurationChoices; 19 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.CountryOnly; 20 | 21 | import spock.lang.Specification; 22 | import spock.lang.Unroll; 23 | 24 | /** 25 | * Test for CountryOnly 26 | * 27 | * @author Philip Vendil, p.vendil@cgi.com 28 | * 29 | */ 30 | class CountryOnlySpec extends BaseStructSpec { 31 | 32 | @Unroll 33 | def "Verify constructors"(){ 34 | when: 35 | def e1 = new CountryOnly(10) 36 | 37 | then: 38 | serializeToHex(e1) == "000a" 39 | 40 | when: 41 | CountryOnly e2 = deserializeFromHex(new CountryOnly(), "000a") 42 | 43 | then: 44 | e2.getValueAsLong() == 10 45 | } 46 | 47 | 48 | def "Verify CountryOnly toString"(){ 49 | expect: 50 | new CountryOnly(1000).toString() == "CountryOnly [1000]" 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/etsits102941/v131/MessageProcessingExceptionSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.etsits102941.v131 14 | 15 | import org.certificateservices.custom.c2x.ieee1609dot2.generator.receiver.Receiver 16 | import spock.lang.Specification 17 | 18 | import javax.crypto.SecretKey 19 | 20 | /** 21 | * Unit tests for MessageProcessingException 22 | */ 23 | class MessageProcessingExceptionSpec extends Specification { 24 | 25 | byte[] requestHash = [1,2,3] as byte[] 26 | 27 | def "Verify that constructor populates fields correctly"(){ 28 | setup: 29 | def key = Mock(SecretKey) 30 | def receiver = Mock(Receiver) 31 | def cause = new IOException() 32 | when: 33 | def e1 = new MessageProcessingException("SomeMessage", key) 34 | then: 35 | e1.message == "SomeMessage" 36 | e1.getSecretKey() == key 37 | 38 | when: 39 | def e2 = new MessageProcessingException("SomeMessage", cause ,key, requestHash, receiver) 40 | then: 41 | e2.message == "SomeMessage" 42 | e2.cause == cause 43 | e2.getSecretKey() == key 44 | e2.getReceiver() == receiver 45 | e2.getRequestHash() == requestHash 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/etsits102941/v131/datastructs/trustlist/FullCtl.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.etsits102941.v131.datastructs.trustlist; 14 | 15 | import org.certificateservices.custom.c2x.common.BadArgumentException; 16 | import org.certificateservices.custom.c2x.etsits102941.v131.datastructs.basetypes.Version; 17 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.Time32; 18 | 19 | import java.io.IOException; 20 | 21 | /** 22 | * Class representing FullCtl defined in ETSI TS 102 941 Trust List Types 23 | * 24 | * @author Philip Vendil, p.vendil@cgi.com 25 | * 26 | */ 27 | public class FullCtl extends CtlFormat { 28 | 29 | private static final long serialVersionUID = 1L; 30 | 31 | /** 32 | * Constructor used when decoding 33 | */ 34 | public FullCtl(){ 35 | super(); 36 | } 37 | 38 | /** 39 | * Constructor used when encoding 40 | */ 41 | public FullCtl(Version version, Time32 nextUpdate, int ctlSequence, CtlCommand[] ctlCommands) throws IOException, BadArgumentException { 42 | super(version,nextUpdate,true,ctlSequence,ctlCommands); 43 | } 44 | 45 | 46 | @Override 47 | public String toString() { 48 | return super.toString().replaceAll("CtlFormat ","FullCtl "); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/p2p/CaCertP2pPDU.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.p2p; 14 | 15 | import java.util.List; 16 | 17 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.cert.Certificate; 18 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.cert.SequenceOfCertificate; 19 | 20 | 21 | /** 22 | * This class extends SequenceOfCertificate used in Ieee1609dot2Peer2PeerPDU structure. 23 | * 24 | * @author Philip Vendil, p.vendil@cgi.com 25 | * 26 | */ 27 | public class CaCertP2pPDU extends SequenceOfCertificate { 28 | 29 | private static final long serialVersionUID = 1L; 30 | 31 | /** 32 | * Constructor used when decoding 33 | */ 34 | public CaCertP2pPDU() { 35 | super(); 36 | } 37 | 38 | /** 39 | * Constructor used when encoding 40 | */ 41 | public CaCertP2pPDU(Certificate[] sequenceValues) { 42 | super(sequenceValues); 43 | } 44 | 45 | /** 46 | * Constructor used when encoding 47 | */ 48 | public CaCertP2pPDU(List sequenceValues) { 49 | super(sequenceValues); 50 | } 51 | 52 | 53 | @Override 54 | public String toString() { 55 | return super.toString().replace("SequenceOfCertificate", "CaCertP2pPDU"); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/asn1/coer/TestCOEREnumeration.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.asn1.coer; 14 | 15 | import java.io.DataInputStream; 16 | import java.io.DataOutputStream; 17 | import java.io.IOException; 18 | 19 | import org.certificateservices.custom.c2x.common.Encodable; 20 | 21 | public enum TestCOEREnumeration implements COERChoiceEnumeration { 22 | CHOICE1(new COERInteger(0,8)), 23 | CHOICE2(new COEROctetStream()), 24 | CHOICE3(new COERInteger(0,10)); 25 | 26 | 27 | private byte[] emptyCOEREncodableData; 28 | private TestCOEREnumeration(COEREncodable emptyCOEREncodable){ 29 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 30 | ObjectOutputStream oos = new ObjectOutputStream(baos) 31 | oos.writeObject(emptyCOEREncodable) 32 | this.emptyCOEREncodableData = baos.toByteArray(); 33 | } 34 | 35 | @Override 36 | public COEREncodable getEmptyCOEREncodable() throws IOException{ 37 | ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(emptyCOEREncodableData)); 38 | return ois.readObject(); 39 | } 40 | 41 | /** 42 | * 43 | * @return true if this entry is an extension or false if regular choice 44 | */ 45 | @Override 46 | boolean isExtension() { 47 | return false 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/etsits102941/v131/datastructs/trustlist/DeltaCtl.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.etsits102941.v131.datastructs.trustlist; 14 | 15 | import org.certificateservices.custom.c2x.common.BadArgumentException; 16 | import org.certificateservices.custom.c2x.etsits102941.v131.datastructs.basetypes.Version; 17 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.Time32; 18 | 19 | import java.io.IOException; 20 | 21 | /** 22 | * Class representing DeltaCtl defined in ETSI TS 102 941 Trust List Types 23 | * 24 | * @author Philip Vendil, p.vendil@cgi.com 25 | * 26 | */ 27 | public class DeltaCtl extends CtlFormat { 28 | 29 | private static final long serialVersionUID = 1L; 30 | 31 | /** 32 | * Constructor used when decoding 33 | */ 34 | public DeltaCtl(){ 35 | super(); 36 | } 37 | 38 | /** 39 | * Constructor used when encoding 40 | */ 41 | public DeltaCtl(Version version, Time32 nextUpdate, int ctlSequence, CtlCommand[] ctlCommands) throws IOException, BadArgumentException { 42 | super(version,nextUpdate,false,ctlSequence,ctlCommands); 43 | } 44 | 45 | 46 | @Override 47 | public String toString() { 48 | return super.toString().replaceAll("CtlFormat ","DeltaCtl "); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/LaIdSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic 14 | 15 | import java.security.MessageDigest 16 | 17 | import org.bouncycastle.util.encoders.Hex; 18 | import org.certificateservices.custom.c2x.common.BaseStructSpec; 19 | import org.certificateservices.custom.c2x.common.crypto.DefaultCryptoManagerParams; 20 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.LaId; 21 | 22 | import spock.lang.Specification; 23 | import spock.lang.Unroll; 24 | 25 | /** 26 | * Test for LaId 27 | * 28 | * @author Philip Vendil, p.vendil@cgi.com 29 | * 30 | */ 31 | class LaIdSpec extends BaseStructSpec { 32 | 33 | byte[] laid = Hex.decode("0102") 34 | 35 | 36 | 37 | 38 | def "Verify that LaId stores the data correctly"(){ 39 | when: 40 | LaId h1 = new LaId(laid) 41 | then: 42 | h1.getLaId() == laid; // verify the methods returns the same data 43 | h1.getLaId().length == 2 44 | serializeToHex(h1) == "0102" 45 | 46 | when: 47 | LaId h2 = deserializeFromHex(new LaId(), "0102") 48 | then: 49 | h2.getLaId() == laid 50 | } 51 | 52 | def "Verify toString"(){ 53 | expect: 54 | new LaId(laid).toString() == "LaId [0102]" 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/etsits102941/v131/SignatureVerificationExceptionSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.etsits102941.v131 14 | 15 | import org.certificateservices.custom.c2x.ieee1609dot2.generator.receiver.Receiver 16 | import spock.lang.Specification 17 | 18 | import javax.crypto.SecretKey 19 | 20 | /** 21 | * Unit tests for SignatureVerificationException 22 | */ 23 | class SignatureVerificationExceptionSpec extends Specification { 24 | 25 | byte[] requestHash = [1,2,3] as byte[] 26 | 27 | def "Verify that constructor populates fields correctly"(){ 28 | setup: 29 | def key = Mock(SecretKey) 30 | def receiver = Mock(Receiver) 31 | def cause = new IOException() 32 | when: 33 | def e1 = new SignatureVerificationException("SomeMessage", key) 34 | then: 35 | e1.message == "SomeMessage" 36 | e1.getSecretKey() == key 37 | 38 | when: 39 | def e2 = new SignatureVerificationException("SomeMessage", cause ,key, requestHash, receiver) 40 | then: 41 | e2.message == "SomeMessage" 42 | e2.cause == cause 43 | e2.getSecretKey() == key 44 | e2.getReceiver() == receiver 45 | e2.getRequestHash() == requestHash 46 | } 47 | } -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/etsits102941/v131/DecryptionFailedExceptionSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.etsits102941.v131 14 | 15 | import org.certificateservices.custom.c2x.ieee1609dot2.generator.receiver.Receiver 16 | import spock.lang.Specification 17 | 18 | import javax.crypto.SecretKey 19 | 20 | /** 21 | * Unit tests for DecryptionFailedException 22 | */ 23 | class DecryptionFailedExceptionSpec extends Specification { 24 | 25 | byte[] requestHash = [1,2,3] as byte[] 26 | 27 | def "Verify that constructor populates fields correctly"(){ 28 | setup: 29 | def key = Mock(SecretKey) 30 | def receiver = Mock(Receiver) 31 | def cause = new IOException() 32 | when: 33 | def e1 = new DecryptionFailedException("SomeMessage", cause) 34 | then: 35 | e1.message == "SomeMessage" 36 | e1.cause == cause 37 | e1.getSecretKey() == null 38 | 39 | when: 40 | def e2 = new DecryptionFailedException("SomeMessage", cause ,key, requestHash, receiver) 41 | then: 42 | e2.message == "SomeMessage" 43 | e2.cause == cause 44 | e2.getReceiver() == receiver 45 | e2.getSecretKey() == key 46 | e2.getRequestHash() == requestHash 47 | } 48 | } -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/etsits102941/v131/generator/ETSITS102941SecureDataGeneratorSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.etsits102941.v131.generator 14 | 15 | import org.bouncycastle.jce.provider.BouncyCastleProvider 16 | import org.certificateservices.custom.c2x.ieee1609dot2.crypto.Ieee1609Dot2CryptoManager 17 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.HashAlgorithm 18 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.Signature 19 | import spock.lang.Specification 20 | 21 | import java.security.Security 22 | 23 | /** 24 | * Unit tests for ETSITS102941SecureDataGenerator 25 | * @author Philip Vendil, p.vendil@cgi.com 26 | */ 27 | class ETSITS102941SecureDataGeneratorSpec extends Specification { 28 | 29 | def setupSpec(){ 30 | Security.addProvider(new BouncyCastleProvider()) 31 | } 32 | def "Verify constructor"(){ 33 | when: 34 | ETSITS102941SecureDataGenerator g = new ETSITS102941SecureDataGenerator(2,Mock(Ieee1609Dot2CryptoManager), HashAlgorithm.sha384, Signature.SignatureChoices.ecdsaBrainpoolP384r1Signature) 35 | then: 36 | g.cryptoManager != null 37 | } 38 | 39 | // newEncryptedDataStructure is tested in ETSITS102941MessagesCaGenerator 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/common/validator/TimeValidator.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.common.validator; 14 | 15 | import org.certificateservices.custom.c2x.common.BadArgumentException; 16 | import org.certificateservices.custom.c2x.common.Certificate; 17 | import java.util.Date; 18 | 19 | /** 20 | * Interface for validating the time of a certificate or certificate chain 21 | * 22 | * @author Philip Vendil, p.vendil@cgi.com 23 | */ 24 | public interface TimeValidator { 25 | 26 | /** 27 | * Method to verify that the given certificates are valid against the specified time. 28 | * 29 | * @param currentTime the expected time to verify the certificate against. 30 | * @param certificateChain the certificate to verify region in, end entity certificate first and root cert last. 31 | * @param entireChain if entireChain should be validated or only first certificate in chain. 32 | * @throws InvalidCertificateException if the given certificate chain was invalid for the specified time. 33 | * @throws BadArgumentException if other argument was invalid when validation the certificate. 34 | */ 35 | void validateTime(Date currentTime, Certificate[] certificateChain, boolean entireChain) throws BadArgumentException, InvalidCertificateException; 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/KnownLongitude.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | import java.math.BigInteger; 16 | 17 | 18 | /** 19 | * The longitude field contains an INTEGER encoding an estimate of the longitude with precision 1/10th microdegree relative to the 20 | * World Geodetic System (WGS)-84 datum as defined in NIMA Technical Report TR8350.2. 21 | *

22 | * The integer in the longitude field is no more than 1 800 000 000 and no less than -1 799 999 999. 23 | * 24 | * @author Philip Vendil, p.vendil@cgi.com 25 | * 26 | */ 27 | public class KnownLongitude extends OneEightyDegreeInt { 28 | 29 | private static final long serialVersionUID = 1L; 30 | 31 | /** 32 | * Constructor used when decoding. 33 | */ 34 | public KnownLongitude(){ 35 | super(); 36 | maxValue = BigInteger.valueOf(MAX); 37 | } 38 | 39 | /** 40 | * Constructor used when encoding 41 | * @param value between -900000000 and 900000000 (Unknown 900000001) 42 | */ 43 | public KnownLongitude(long value) { 44 | super(value); 45 | maxValue = BigInteger.valueOf(MAX); 46 | } 47 | 48 | @Override 49 | public String toString() { 50 | return "KnownLongitude [" + getValueAsLong() +"]"; 51 | } 52 | 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/common/validator/RegionValidator.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.common.validator; 14 | 15 | import org.certificateservices.custom.c2x.common.BadArgumentException; 16 | import org.certificateservices.custom.c2x.common.Certificate; 17 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.GeographicRegion; 18 | 19 | /** 20 | * Interface for implementing 21 | * 22 | * @author Philip Vendil, p.vendil@cgi.com 23 | */ 24 | public interface RegionValidator { 25 | 26 | /** 27 | * Method to verify that the region in certificate matches the requirement in the 28 | * issuer certificate. If certificate is self-signed it ignore the certificate. 29 | * 30 | * @param checkRegion the expected region to validate the certificate for. 31 | * @param certificateChain the certificate to verify region in, end entity certificate first and root cert last. 32 | * 33 | * @throws InvalidCertificateException if region in given certificate was invalid. 34 | * @throws BadArgumentException if other argument was invalid not related to the region in the certificate. 35 | */ 36 | void validateRegion(GeographicRegion checkRegion, Certificate[] certificateChain) throws BadArgumentException, InvalidCertificateException; 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/KnownLatitude.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | import java.io.IOException; 16 | import java.math.BigInteger; 17 | 18 | 19 | /** 20 | * The latitude field contains an INTEGER encoding an estimate of the latitude with precision 1/10th 21 | * microdegree relative to the World Geodetic System (WGS)-84 datum as defined in NIMA Technical Report TR8350.2. 22 | *

23 | * The integer in the latitude field is no more than 900 000 000 and no less than -900 000 000. 24 | * 25 | * @author Philip Vendil, p.vendil@cgi.com 26 | * 27 | */ 28 | public class KnownLatitude extends NinetyDegreeInt { 29 | 30 | private static final long serialVersionUID = 1L; 31 | 32 | /** 33 | * Constructor used when decoding. 34 | */ 35 | public KnownLatitude(){ 36 | super(); 37 | maxValue = BigInteger.valueOf(MAX); 38 | } 39 | 40 | /** 41 | * Constructor used when encoding 42 | * @param value between -900000000 and 900000000 (Unknown 900000001) 43 | */ 44 | public KnownLatitude(long value) { 45 | super(value); 46 | maxValue = BigInteger.valueOf(MAX); 47 | } 48 | 49 | @Override 50 | public String toString() { 51 | return "KnownLatitude [" + getValueAsLong() +"]"; 52 | } 53 | 54 | 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/common/validator/InvalidCRLException.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.common.validator; 14 | 15 | /** 16 | * Exception thrown by the validator if CRL is invalid. 17 | * 18 | * @author Philip Vendil, p.vendil@cgi.com 19 | */ 20 | public class InvalidCRLException extends Exception{ 21 | 22 | /** 23 | * Exception thrown by the validator if CRL is invalid. 24 | * 25 | * @param message the detail message. The detail message is saved for 26 | * later retrieval by the {@link #getMessage()} method. 27 | */ 28 | public InvalidCRLException(String message) { 29 | super(message); 30 | } 31 | 32 | /** 33 | * Exception thrown by the validator if CRL is invalid. 34 | * 35 | * @param message the detail message (which is saved for later retrieval 36 | * by the {@link #getMessage()} method). 37 | * @param cause the cause (which is saved for later retrieval by the 38 | * {@link #getCause()} method). (A null value is 39 | * permitted, and indicates that the cause is nonexistent or 40 | * unknown.) 41 | */ 42 | public InvalidCRLException(String message, Throwable cause) { 43 | super(message, cause); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/common/validator/InvalidCTLException.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.common.validator; 14 | 15 | /** 16 | * Exception thrown by the validator if CTL is invalid. 17 | * 18 | * @author Philip Vendil, p.vendil@cgi.com 19 | */ 20 | public class InvalidCTLException extends Exception{ 21 | 22 | /** 23 | * Exception thrown by the validator if CTL is invalid. 24 | * 25 | * @param message the detail message. The detail message is saved for 26 | * later retrieval by the {@link #getMessage()} method. 27 | */ 28 | public InvalidCTLException(String message) { 29 | super(message); 30 | } 31 | 32 | /** 33 | * Exception thrown by the validator if CTL is invalid. 34 | * 35 | * @param message the detail message (which is saved for later retrieval 36 | * by the {@link #getMessage()} method). 37 | * @param cause the cause (which is saved for later retrieval by the 38 | * {@link #getCause()} method). (A null value is 39 | * permitted, and indicates that the cause is nonexistent or 40 | * unknown.) 41 | */ 42 | public InvalidCTLException(String message, Throwable cause) { 43 | super(message, cause); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/generator/receiver/SignedDataReciever.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.generator.receiver; 14 | 15 | import java.io.IOException; 16 | import java.security.PrivateKey; 17 | 18 | import org.certificateservices.custom.c2x.common.crypto.AlgorithmIndicator; 19 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.HashAlgorithm; 20 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.secureddata.Ieee1609Dot2Data; 21 | 22 | /** 23 | * Receiver using public key based on signed data structure. 24 | * 25 | * @author Philip Vendil p.vendil@cgi.com 26 | * 27 | */ 28 | public class SignedDataReciever extends BasePKReceiver { 29 | 30 | private Ieee1609Dot2Data signedData; 31 | 32 | public SignedDataReciever(PrivateKey privateKey, Ieee1609Dot2Data signedData) { 33 | super(privateKey); 34 | this.signedData = signedData; 35 | } 36 | 37 | @Override 38 | protected byte[] getReferenceData() throws IOException { 39 | return signedData.getEncoded(); 40 | } 41 | 42 | /** 43 | * @return the hash algorithm used to calculate the related HashedId8 reference. 44 | */ 45 | @Override 46 | public AlgorithmIndicator getHashAlgorithm() { 47 | return HashAlgorithm.sha256; // Only sha256 signed data is supported using ecies. 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/HashAlgorithm.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | import org.certificateservices.custom.c2x.asn1.coer.COEREnumerationType; 16 | import org.certificateservices.custom.c2x.common.crypto.Algorithm; 17 | import org.certificateservices.custom.c2x.common.crypto.AlgorithmIndicator; 18 | 19 | /** 20 | * This structure identifies a hash algorithm. SHA-256 as specified in 5.3.3. The value sha384 indicates SHA-384 as specified in 5.3.3. 21 | * 22 | * Critical information fields: This is a critical information field as defined in 5.2.5. An implementation that does not recognize 23 | * the enumerated value of this type in a signed SPDU when verifying a signed SPDU shall indicate that the signed SPDU is invalid. 24 | * 25 | * @author Philip Vendil, p.vendil@cgi.com 26 | * 27 | */ 28 | public enum HashAlgorithm implements COEREnumerationType, AlgorithmIndicator { 29 | sha256(Algorithm.Hash.sha256), 30 | sha384(Algorithm.Hash.sha384); 31 | 32 | private Algorithm.Hash relatedHash; 33 | 34 | HashAlgorithm(Algorithm.Hash relatedHash){ 35 | this.relatedHash = relatedHash; 36 | } 37 | 38 | @Override 39 | public Algorithm getAlgorithm() { 40 | return new Algorithm(null,null,null,relatedHash); 41 | } 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/Latitude.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | 16 | import java.io.IOException; 17 | 18 | /** 19 | * The latitude field contains an INTEGER encoding an estimate of the latitude with precision 1/10th 20 | * microdegree relative to the World Geodetic System (WGS)-84 datum as defined in NIMA Technical Report TR8350.2. 21 | *

22 | * The integer in the latitude field is no more than 900 000 000 and no less than -900 000 000, 23 | * except that the value 900 000 001 is used to indicate the latitude was not available to the sender. 24 | * 25 | * @author Philip Vendil, p.vendil@cgi.com 26 | * 27 | */ 28 | public class Latitude extends NinetyDegreeInt { 29 | 30 | 31 | private static final long serialVersionUID = 1L; 32 | 33 | /** 34 | * Constructor used when decoding. 35 | */ 36 | public Latitude(){ 37 | super(); 38 | } 39 | 40 | /** 41 | * Constructor used when encoding 42 | * @param value between -900000000 and 900000000 (Unkown 900000001) 43 | */ 44 | public Latitude(long value) throws IOException { 45 | super(value); 46 | } 47 | 48 | @Override 49 | public String toString() { 50 | long val = getValueAsLong(); 51 | return "Latitude [" + (val!= UNKNOWN ? val : "UNKNOWN") +"]"; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/etsits102941/v131/datastructs/authorizationvalidation/AuthorizationValidationResponseCodeSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.etsits102941.v131.datastructs.authorizationvalidation 14 | 15 | import spock.lang.Specification 16 | import spock.lang.Unroll 17 | 18 | import static AuthorizationValidationResponseCode.* 19 | /** 20 | * Unit tests for AuthorizationValidationResponseCode. 21 | * 22 | * @author Philip Vendil, p.vendil@cgi.com 23 | */ 24 | class AuthorizationValidationResponseCodeSpec extends Specification { 25 | 26 | @Unroll 27 | def "Verify that #value have the following ordinal #ordinal"(){ 28 | expect: 29 | value.ordinal() == ordinal 30 | 31 | where: 32 | ordinal | value 33 | 0 | ok 34 | 1 | cantparse 35 | 2 | badcontenttype 36 | 3 | imnottherecipient 37 | 4 | unknownencryptionalgorithm 38 | 5 | decryptionfailed 39 | 6 | invalidaa 40 | 7 | invalidaasignature 41 | 8 | wrongea 42 | 9 | unknownits 43 | 10 | invalidsignature 44 | 11 | invalidencryptionkey 45 | 12 | deniedpermissions 46 | 13 | deniedtoomanycerts 47 | 14 | deniedrequest 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/ieee1609dot2/generator/DecryptResultSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.generator 14 | 15 | import org.bouncycastle.util.encoders.Hex 16 | import org.certificateservices.custom.c2x.ieee1609dot2.generator.receiver.Receiver 17 | import spock.lang.Specification 18 | 19 | import javax.crypto.SecretKey 20 | 21 | /** 22 | * Unit tests for DecryptResult. 23 | * 24 | * @author Philip Vendil, p.vendil@cgi.com 25 | */ 26 | class DecryptResultSpec extends Specification { 27 | 28 | Receiver receiver = Mock(Receiver) 29 | SecretKey secretKey = Mock(SecretKey) 30 | byte[] data = Hex.decode("313233") 31 | 32 | def "Verify constructor and getters"(){ 33 | when: 34 | DecryptResult dr = new DecryptResult(receiver, secretKey,data) 35 | then: 36 | dr.receiver == receiver 37 | dr.secretKey == secretKey 38 | dr.data == data 39 | } 40 | 41 | def "Verify toString()"(){ 42 | expect: 43 | new DecryptResult(receiver,secretKey,data).toString() == """DecryptAndVerifyResult [ 44 | receiver=EXISTS, 45 | secretKey=EXISTS, 46 | data=313233 47 | ]""" 48 | new DecryptResult(null,null,data).toString() == """DecryptAndVerifyResult [ 49 | receiver=NONE, 50 | secretKey=NONE, 51 | data=313233 52 | ]""" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/LaId.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | import org.bouncycastle.util.encoders.Hex; 16 | import org.certificateservices.custom.c2x.asn1.coer.COEROctetStream; 17 | 18 | import java.io.IOException; 19 | 20 | /** 21 | * This structure contains a LA Identifier for use in the algorithms specified in 5.1.3.4. 22 | * 23 | * @author Philip Vendil, p.vendil@cgi.com 24 | * 25 | */ 26 | public class LaId extends COEROctetStream{ 27 | 28 | private static final int OCTETSTRING_SIZE = 2; 29 | private static final long serialVersionUID = 1L; 30 | 31 | 32 | /** 33 | * Constructor used during decoding. 34 | * 35 | */ 36 | public LaId(){ 37 | super(OCTETSTRING_SIZE, OCTETSTRING_SIZE); 38 | } 39 | 40 | /** 41 | * Constructor used to create a LaId. 42 | * @param laId a 2 byte array. 43 | * @throws IOException if laId was invalid 44 | */ 45 | public LaId(byte[] laId) throws IOException { 46 | super(laId, OCTETSTRING_SIZE, OCTETSTRING_SIZE); 47 | 48 | } 49 | 50 | /** 51 | * @return the linkage value, same as getData() method. 52 | */ 53 | public byte[] getLaId(){ 54 | return data; 55 | } 56 | 57 | @Override 58 | public String toString() { 59 | return "LaId [" + new String(Hex.encode(data)) + "]"; 60 | } 61 | 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/etsits102941/v131/datastructs/enrollment/EnrollmentResponseCode.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.etsits102941.v131.datastructs.enrollment; 14 | 15 | import org.certificateservices.custom.c2x.asn1.coer.COEREnumerationType; 16 | 17 | /** 18 | * Class representing enumeration EnrollmentResponseCode defined in ETSI TS 102 941 Enrollment Types 19 | * @author Philip Vendil, p.vendil@cgi.com 20 | */ 21 | public enum EnrollmentResponseCode implements COEREnumerationType { 22 | ok, 23 | cantparse, // valid for any structure 24 | badcontenttype, // not encrypted, not signed, not enrolmentrequest 25 | imnottherecipient, // the "recipients" doesn’t include me 26 | unknownencryptionalgorithm, // either kexalg or contentencryptionalgorithm 27 | decryptionfailed, // works for ECIES-HMAC and AES-CCM 28 | unknownits, // can’t retrieve the ITS from the itsId 29 | invalidsignature, // signature verification of the request fails 30 | invalidencryptionkey, // signature is good, but the responseEncryptionKey is bad 31 | baditsstatus, // revoked, not yet active 32 | incompleterequest, // some elements are missing 33 | deniedpermissions, // requested permissions are not granted 34 | invalidkeys, // either the verification_key of the encryption_key is bad 35 | deniedrequest, // any other reason? 36 | } 37 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/asn1/coer/COERIA5StringSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.asn1.coer 14 | 15 | import org.certificateservices.custom.c2x.common.BadArgumentException 16 | import org.certificateservices.custom.c2x.common.BaseStructSpec 17 | 18 | /** 19 | * Unit tests for COERIA5String 20 | * 21 | * @author Philip Vendil, p.vendil@cgi.com 22 | */ 23 | class COERIA5StringSpec extends BaseStructSpec { 24 | 25 | def "Verify that constructor and getter"(){ 26 | expect: 27 | new COERIA5String(4,5).getLowerBound() == 4 28 | new COERIA5String(4,5).getUpperBound() == 5 29 | new COERIA5String("a").getAI5String() == "a" 30 | new COERIA5String("a",1,5).getLowerBound() == 1 31 | new COERIA5String("a",1,5).getUpperBound() == 5 32 | new COERIA5String("ab",1,5).getAI5String() == "ab" 33 | } 34 | 35 | def "Verify that constructor throws IOException if IA5 string contains invalid values"(){ 36 | when: 37 | new COERIA5String("ä") 38 | then: 39 | def e = thrown IOException 40 | e.message == "Invalid IA5String characters in string: ä" 41 | when: 42 | new COERIA5String("ä",1,5) 43 | then: 44 | e = thrown IOException 45 | e.message == "Invalid IA5String characters in string: ä" 46 | } 47 | 48 | def "Verify toString"(){ 49 | expect: 50 | new COERIA5String("ab").toString() == "COERIA5String [IA5String=ab]" 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/Longitude.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | 16 | import java.io.IOException; 17 | 18 | /** 19 | * The longitude field contains an INTEGER encoding an estimate of the longitude with precision 1/10th microdegree relative to the 20 | * World Geodetic System (WGS)-84 datum as defined in NIMA Technical Report TR8350.2. 21 | *

22 | * The integer in the longitude field is no more than 1 800 000 000 and no less than -1 799 999 999, except that the 23 | * value 1 800 000 001 is used to indicate that the longitude was not available to the sender. 24 | * 25 | * @author Philip Vendil, p.vendil@cgi.com 26 | * 27 | */ 28 | public class Longitude extends OneEightyDegreeInt { 29 | 30 | private static final long serialVersionUID = 1L; 31 | 32 | /** 33 | * Constructor used when decoding. 34 | */ 35 | public Longitude() { 36 | super(); 37 | } 38 | 39 | /** 40 | * Constructor used when encoding 41 | * @param value no more than 1 800 000 000 and no less than -1 799 999 999 or 1 800 000 001 for UNKNOWN 42 | */ 43 | public Longitude(long value) throws IOException { 44 | super(value); 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | long val = getValueAsLong(); 50 | return "Longitude [" + (val!= UNKNOWN ? val : "UNKNOWN") +"]"; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/enc/PreSharedKeyRecipientInfo.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.enc; 14 | 15 | import org.bouncycastle.util.encoders.Hex; 16 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.HashedId8; 17 | 18 | import java.io.IOException; 19 | 20 | /** 21 | * This data structure is used to indicate a symmetric key that may be used directly to decrypt a 22 | * SymmetricCiphertext. It consists of the low-order 8 bytes of the SHA-256 hash of the COER encoding of a 23 | * SymmetricEncryptionKey structure containing the symmetric key in question. The symmetric key may be 24 | * established by any appropriate means agreed by the two parties to the exchange. 25 | * 26 | * @author Philip Vendil, p.vendil@cgi.com 27 | * 28 | */ 29 | public class PreSharedKeyRecipientInfo extends HashedId8 { 30 | 31 | 32 | private static final long serialVersionUID = 1L; 33 | 34 | /** 35 | * Constructor used when decoding 36 | */ 37 | public PreSharedKeyRecipientInfo(){ 38 | } 39 | 40 | /** 41 | * Constructor used when encoding 42 | */ 43 | public PreSharedKeyRecipientInfo(byte[] recipientInfo) throws IOException { 44 | super(recipientInfo); 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "PreSharedKeyRecipientInfo [" + new String(Hex.encode(getHashedId())) + "]"; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/BitmapSspSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic 14 | 15 | import org.bouncycastle.util.encoders.Hex 16 | import spock.lang.Specification 17 | 18 | /** 19 | * Unit tests for BitmapSsp 20 | * 21 | * @author Philip Vendil, p.vendil@cgi.com 22 | */ 23 | class BitmapSspSpec extends Specification { 24 | 25 | def "Verify that empty data is allowed"(){ 26 | expect: 27 | new BitmapSsp(new byte[0]).getData() == new byte[0] 28 | } 29 | 30 | def "Verify that IOException is thrown for data larger that max size"(){ 31 | when: 32 | new BitmapSsp(new byte[32]) 33 | then: 34 | def e = thrown IOException 35 | e.message == "Error given data to octet stream is larger than maximal value of 31" 36 | } 37 | 38 | def "Verify that data is stored correctly"(){ 39 | expect: 40 | Hex.toHexString(new BitmapSsp(Hex.decode("01020304050607080910010203040506070809100102030405060708091001")).getData()) == "01020304050607080910010203040506070809100102030405060708091001" 41 | } 42 | 43 | def "Verify toString()"(){ 44 | expect: 45 | new BitmapSsp(Hex.decode("01020304050607080910010203040506070809100102030405060708091001")).toString() == "BitmapSsp [01020304050607080910010203040506070809100102030405060708091001]" 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/LinkageSeed.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | import org.bouncycastle.util.encoders.Hex; 16 | import org.certificateservices.custom.c2x.asn1.coer.COEROctetStream; 17 | 18 | import java.io.IOException; 19 | 20 | /** 21 | * This structure contains a linkage seed value for use in the algorithms specified in 5.1.3.4. 22 | * 23 | * @author Philip Vendil, p.vendil@cgi.com 24 | * 25 | */ 26 | public class LinkageSeed extends COEROctetStream{ 27 | 28 | private static final int OCTETSTRING_SIZE = 16; 29 | private static final long serialVersionUID = 1L; 30 | 31 | 32 | /** 33 | * Constructor used during decoding. 34 | * 35 | */ 36 | public LinkageSeed(){ 37 | super(OCTETSTRING_SIZE, OCTETSTRING_SIZE); 38 | } 39 | 40 | /** 41 | * Constructor used to create a linkageSeed. 42 | * @param linkageSeed a 16 byte array. 43 | * @throws IOException if linkageSeed was invalid 44 | */ 45 | public LinkageSeed(byte[] linkageSeed) throws IOException { 46 | super(linkageSeed, OCTETSTRING_SIZE, OCTETSTRING_SIZE); 47 | 48 | } 49 | 50 | /** 51 | * @return the linkage seed, same as getData() method. 52 | */ 53 | public byte[] getLinkageSeed(){ 54 | return data; 55 | } 56 | 57 | @Override 58 | public String toString() { 59 | return "LinkageSeed [" + new String(Hex.encode(data)) + "]"; 60 | } 61 | 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/LinkageValue.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | import org.bouncycastle.util.encoders.Hex; 16 | import org.certificateservices.custom.c2x.asn1.coer.COEROctetStream; 17 | 18 | import java.io.IOException; 19 | 20 | /** 21 | * This is the individual linkage value. See 5.1.3 and 7.3 for details of use. 22 | * 23 | * @author Philip Vendil, p.vendil@cgi.com 24 | * 25 | */ 26 | public class LinkageValue extends COEROctetStream{ 27 | 28 | private static final int OCTETSTRING_SIZE = 9; 29 | private static final long serialVersionUID = 1L; 30 | 31 | 32 | /** 33 | * Constructor used during decoding. 34 | * 35 | */ 36 | public LinkageValue(){ 37 | super(OCTETSTRING_SIZE, OCTETSTRING_SIZE); 38 | } 39 | 40 | /** 41 | * Constructor used to create a linkageValue value. 42 | * @param linkageValue a 9 byte array. 43 | * @throws IOException if linkageValue was invalid 44 | */ 45 | public LinkageValue(byte[] linkageValue) throws IOException { 46 | super(linkageValue, OCTETSTRING_SIZE, OCTETSTRING_SIZE); 47 | 48 | } 49 | 50 | /** 51 | * @return the linkage value, same as getData() method. 52 | */ 53 | public byte[] getLinkageValue(){ 54 | return data; 55 | } 56 | 57 | @Override 58 | public String toString() { 59 | return "LinkageValue [" + new String(Hex.encode(data)) + "]"; 60 | } 61 | 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/common/CountryCode.java: -------------------------------------------------------------------------------- 1 | package org.certificateservices.custom.c2x.common; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | /** 7 | * Enumeration listing available country code value according to 8 | * C-ITS Point of Contact (CPOC) RCA certificate requirements & best practices. Draft v0.5, October 2019 9 | * 10 | * @author Lu Han 2020-03-10 11 | */ 12 | public class CountryCode { 13 | 14 | private final static int AUSTRIA = 40; 15 | private final static int BELGIUM = 56; 16 | private final static int BULGARIA = 100; 17 | private final static int CROATIA = 191; 18 | private final static int REPUBLICOFCYPRUS = 196; 19 | private final static int CZECHREPUBLIC = 203; 20 | private final static int DENMARK = 208; 21 | private final static int ESTONIA = 233; 22 | private final static int FINLAND = 246; 23 | private final static int FRANCE = 250; 24 | private final static int GERMANY = 276; 25 | private final static int GREECE = 300; 26 | private final static int HUNGARY = 348; 27 | private final static int IRELAND = 372; 28 | private final static int ITALY = 380; 29 | private final static int LATVIA = 428; 30 | private final static int LITHUANIA = 440; 31 | private final static int LUXEMBOURG = 442; 32 | private final static int MALTA = 470; 33 | private final static int NETHERLANDS = 528; 34 | private final static int POLAND = 616; 35 | private final static int PORTUGAL = 620; 36 | private final static int ROMANIA = 642; 37 | private final static int SLOVAKIA = 703; 38 | private final static int SLOVENIA = 705; 39 | private final static int SPAIN = 724; 40 | private final static int SWEDEN = 752; 41 | private final static int UK = 826; 42 | 43 | static boolean checkCountryCode(int code) { 44 | List countryCode = Arrays.asList(AUSTRIA, BELGIUM, BULGARIA, CROATIA, REPUBLICOFCYPRUS, CZECHREPUBLIC, 45 | DENMARK, ESTONIA, FINLAND, FRANCE, GERMANY, GREECE, HUNGARY, IRELAND, ITALY, LATVIA, LITHUANIA, LUXEMBOURG, 46 | MALTA, NETHERLANDS, POLAND, PORTUGAL, ROMANIA, SLOVAKIA, SLOVENIA, SPAIN, SWEDEN, UK); 47 | for(int i=0; i sequenceValues){ 48 | super((Psid[]) sequenceValues.toArray(new Psid[sequenceValues.size()])); 49 | } 50 | 51 | 52 | @Override 53 | public String toString() { 54 | String retval = "SequenceOfPsid ["; 55 | if(sequenceValues != null){ 56 | for(int i=0; i< sequenceValues.length -1;i++){ 57 | retval += sequenceValues[i].toString().replace("Psid ", "") + ","; 58 | } 59 | if(sequenceValues.length > 0){ 60 | retval += sequenceValues[sequenceValues.length-1].toString().replace("Psid ", ""); 61 | } 62 | } 63 | retval += "]"; 64 | return retval; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/LinkageValueSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic 14 | 15 | import java.security.MessageDigest 16 | 17 | import org.bouncycastle.util.encoders.Hex; 18 | import org.certificateservices.custom.c2x.common.BaseStructSpec; 19 | import org.certificateservices.custom.c2x.common.crypto.DefaultCryptoManagerParams; 20 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.LinkageValue; 21 | 22 | import spock.lang.Specification; 23 | import spock.lang.Unroll; 24 | 25 | /** 26 | * Test for LinkageValue 27 | * 28 | * @author Philip Vendil, p.vendil@cgi.com 29 | * 30 | */ 31 | class LinkageValueSpec extends BaseStructSpec { 32 | 33 | byte[] linkagevalue = Hex.decode("010203040506070809") 34 | 35 | 36 | 37 | 38 | def "Verify that LinkageValue stores the data correctly"(){ 39 | when: 40 | LinkageValue h1 = new LinkageValue(linkagevalue) 41 | then: 42 | h1.getLinkageValue() == linkagevalue; // verify the methods returns the same data 43 | h1.getLinkageValue().length == 9 44 | serializeToHex(h1) == "010203040506070809" 45 | 46 | when: 47 | LinkageValue h2 = deserializeFromHex(new LinkageValue(), "010203040506070809") 48 | then: 49 | h2.getLinkageValue() == linkagevalue 50 | } 51 | 52 | def "Verify toString"(){ 53 | expect: 54 | new LinkageValue(linkagevalue).toString() == "LinkageValue [010203040506070809]" 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/HashAlgorithmSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic 14 | 15 | import org.certificateservices.custom.c2x.common.BaseStructSpec; 16 | import org.certificateservices.custom.c2x.common.crypto.Algorithm 17 | import org.certificateservices.custom.c2x.common.crypto.DefaultCryptoManagerParams; 18 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.Duration.DurationChoices; 19 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.HashAlgorithm; 20 | 21 | import spock.lang.Specification; 22 | import spock.lang.Unroll; 23 | 24 | /** 25 | * Test for HashAlgorithm 26 | * 27 | * @author Philip Vendil, p.vendil@cgi.com 28 | * 29 | */ 30 | class HashAlgorithmSpec extends BaseStructSpec { 31 | 32 | 33 | def "Verify correct algorithms indicator for sha256 is returned."(){ 34 | when: 35 | Algorithm alg = HashAlgorithm.sha256.getAlgorithm() 36 | then: 37 | alg.getHash() == Algorithm.Hash.sha256 38 | alg.getSymmetric() == null 39 | alg.getSignature() == null 40 | alg.getEncryption() == null 41 | } 42 | 43 | def "Verify correct algorithms indicator for sha384 is returned."(){ 44 | when: 45 | Algorithm alg = HashAlgorithm.sha384.getAlgorithm() 46 | then: 47 | alg.getHash() == Algorithm.Hash.sha384 48 | alg.getSymmetric() == null 49 | alg.getSignature() == null 50 | alg.getEncryption() == null 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/SequenceOfUint8.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | import java.util.List; 16 | 17 | import org.certificateservices.custom.c2x.asn1.coer.COERSequenceOf; 18 | 19 | 20 | /** 21 | * Base type defining a sequence of uint8 22 | * 23 | * @author Philip Vendil, p.vendil@cgi.com 24 | * 25 | */ 26 | public class SequenceOfUint8 extends COERSequenceOf { 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | /** 31 | * Constructor used when decoding 32 | */ 33 | public SequenceOfUint8(){ 34 | super(new Uint8()); 35 | } 36 | 37 | /** 38 | * Constructor used when encoding 39 | */ 40 | public SequenceOfUint8(Uint8[] sequenceValues){ 41 | super(sequenceValues); 42 | } 43 | 44 | /** 45 | * Constructor used when encoding 46 | */ 47 | public SequenceOfUint8(List sequenceValues){ 48 | super((Uint8[]) sequenceValues.toArray(new Uint8[sequenceValues.size()])); 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | String retval = "SequenceOfUint8 ["; 54 | if(sequenceValues != null){ 55 | for(int i=0; i< sequenceValues.length -1;i++){ 56 | retval += ((Uint8) sequenceValues[i]).getValueAsLong() + ","; 57 | } 58 | if(sequenceValues.length > 0){ 59 | retval += ((Uint8) sequenceValues[sequenceValues.length-1]).getValueAsLong(); 60 | } 61 | } 62 | retval += "]"; 63 | return retval; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/SequenceOfUint16.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | import java.util.List; 16 | 17 | import org.certificateservices.custom.c2x.asn1.coer.COERSequenceOf; 18 | 19 | 20 | /** 21 | * Base type defining a sequence of uint16 22 | * 23 | * @author Philip Vendil, p.vendil@cgi.com 24 | * 25 | */ 26 | public class SequenceOfUint16 extends COERSequenceOf { 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | /** 31 | * Constructor used when decoding 32 | */ 33 | public SequenceOfUint16(){ 34 | super(new Uint16()); 35 | } 36 | 37 | /** 38 | * Constructor used when encoding 39 | */ 40 | public SequenceOfUint16(Uint16[] sequenceValues){ 41 | super(sequenceValues); 42 | } 43 | 44 | /** 45 | * Constructor used when encoding 46 | */ 47 | public SequenceOfUint16(List sequenceValues){ 48 | super((Uint16[]) sequenceValues.toArray(new Uint16[sequenceValues.size()])); 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | String retval = "SequenceOfUint16 ["; 54 | if(sequenceValues != null){ 55 | for(int i=0; i< sequenceValues.length -1;i++){ 56 | retval += ((Uint16) sequenceValues[i]).getValueAsLong() + ","; 57 | } 58 | if(sequenceValues.length > 0){ 59 | retval += ((Uint16) sequenceValues[sequenceValues.length-1]).getValueAsLong(); 60 | } 61 | } 62 | retval += "]"; 63 | return retval; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/common/validator/CertificateRevokedException.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.common.validator; 14 | 15 | /** 16 | * Exception thrown by the CRL validator if some certificate is included in a revocation list. 17 | * 18 | * @author Philip Vendil, p.vendil@cgi.com 19 | */ 20 | public class CertificateRevokedException extends Exception{ 21 | 22 | /** 23 | * Exception thrown by the CRL validator if some certificate is included 24 | * in a revocation list. 25 | * 26 | * @param message the detail message. The detail message is saved for 27 | * later retrieval by the {@link #getMessage()} method. 28 | */ 29 | public CertificateRevokedException(String message) { 30 | super(message); 31 | } 32 | 33 | /** 34 | * Exception thrown by the CRL validator if some certificate is included 35 | * in a revocation list. 36 | * 37 | * @param message the detail message (which is saved for later retrieval 38 | * by the {@link #getMessage()} method). 39 | * @param cause the cause (which is saved for later retrieval by the 40 | * {@link #getCause()} method). (A null value is 41 | * permitted, and indicates that the cause is nonexistent or 42 | * unknown.) 43 | */ 44 | public CertificateRevokedException(String message, Throwable cause) { 45 | super(message, cause); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/etsits103097/v131/datastructs/cert/SingleEtsiTs103097Certificate.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.etsits103097.v131.datastructs.cert; 14 | 15 | import org.certificateservices.custom.c2x.asn1.coer.COERSequence; 16 | 17 | import java.io.IOException; 18 | 19 | /** 20 | * Sequence of only one EtsiTs103097Certificate 21 | */ 22 | public class SingleEtsiTs103097Certificate extends COERSequence { 23 | 24 | private static final long serialVersionUID = 1L; 25 | 26 | private static final int ONLY = 0; 27 | 28 | /** 29 | * Constructor used when decoding 30 | */ 31 | public SingleEtsiTs103097Certificate(){ 32 | super(false,1); 33 | init(); 34 | } 35 | 36 | /** 37 | * Constructor used when encoding 38 | */ 39 | public SingleEtsiTs103097Certificate(EtsiTs103097Certificate certificate) throws IOException { 40 | super(false,1); 41 | init(); 42 | set(ONLY, certificate); 43 | } 44 | 45 | /** 46 | * 47 | * @return EtsiTs103097Certificate only 48 | */ 49 | public EtsiTs103097Certificate getOnly(){ 50 | return (EtsiTs103097Certificate) get(ONLY); 51 | } 52 | 53 | 54 | private void init(){ 55 | addField(ONLY, false, new EtsiTs103097Certificate(), null); 56 | 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | return "SingleEtsiTs103097Certificate [only=" + getOnly().toString() + "]"; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/Psid.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | import java.io.IOException; 16 | import java.math.BigInteger; 17 | 18 | import org.certificateservices.custom.c2x.asn1.coer.COERInteger; 19 | 20 | /** 21 | * This type represents the PSID defined in IEEE Std 1609.12. 22 | * 23 | * @author Philip Vendil, p.vendil@cgi.com 24 | * 25 | */ 26 | public class Psid extends COERInteger { 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | /** 31 | * Constructor used when decoding 32 | */ 33 | public Psid(){ 34 | super(BigInteger.ZERO,null); 35 | } 36 | 37 | /** 38 | * Constructor used when encoding 39 | * @param psidValue the integer value of the psid 40 | */ 41 | public Psid(long psidValue) throws IllegalArgumentException { 42 | super(BigInteger.valueOf(psidValue),BigInteger.ZERO,null); 43 | } 44 | 45 | /** 46 | * Constructor used when encoding 47 | * @param psidValueHex psid value in hex format 48 | * @throws NumberFormatException if invalid HEX string was given. 49 | * @throws IOException if encoding problems occurred. 50 | */ 51 | public Psid(String psidValueHex) throws IllegalArgumentException, NumberFormatException{ 52 | super(new BigInteger(psidValueHex, 16),BigInteger.ZERO,null); 53 | } 54 | 55 | @Override 56 | public String toString() { 57 | return "Psid [" + getValue().toString() + "(" + getValue().toString(16)+ ")"+ "]"; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/common/validator/InvalidCertificateException.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.common.validator; 14 | 15 | /** 16 | * Exception thrown by the validator if some certificate permission or validity condition 17 | * fails. 18 | * 19 | * @author Philip Vendil, p.vendil@cgi.com 20 | */ 21 | public class InvalidCertificateException extends Exception{ 22 | 23 | /** 24 | * Exception thrown by the validator if some certificate permission or validity condition 25 | * fails. 26 | * 27 | * @param message the detail message. The detail message is saved for 28 | * later retrieval by the {@link #getMessage()} method. 29 | */ 30 | public InvalidCertificateException(String message) { 31 | super(message); 32 | } 33 | 34 | /** 35 | * Exception thrown by the validator if some certificate permission or validity condition 36 | * fails. 37 | * 38 | * @param message the detail message (which is saved for later retrieval 39 | * by the {@link #getMessage()} method). 40 | * @param cause the cause (which is saved for later retrieval by the 41 | * {@link #getCause()} method). (A null value is 42 | * permitted, and indicates that the cause is nonexistent or 43 | * unknown.) 44 | */ 45 | public InvalidCertificateException(String message, Throwable cause) { 46 | super(message, cause); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/SequenceOfPsidSsp.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic; 14 | 15 | import java.util.List; 16 | 17 | import org.certificateservices.custom.c2x.asn1.coer.COERSequenceOf; 18 | 19 | 20 | /** 21 | * A sequence of type PsidSsp 22 | * 23 | * @author Philip Vendil, p.vendil@cgi.com 24 | * 25 | */ 26 | public class SequenceOfPsidSsp extends COERSequenceOf { 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | /** 31 | * Constructor used when decoding 32 | */ 33 | public SequenceOfPsidSsp(){ 34 | super(new PsidSsp()); 35 | } 36 | 37 | /** 38 | * Constructor used when encoding 39 | */ 40 | public SequenceOfPsidSsp(PsidSsp[] sequenceValues){ 41 | super(sequenceValues); 42 | } 43 | 44 | /** 45 | * Constructor used when encoding 46 | */ 47 | public SequenceOfPsidSsp(List sequenceValues){ 48 | super((PsidSsp[]) sequenceValues.toArray(new PsidSsp[sequenceValues.size()])); 49 | } 50 | 51 | 52 | @Override 53 | public String toString() { 54 | String retval = "SequenceOfPsidSsp ["; 55 | if(sequenceValues != null){ 56 | for(int i=0; i< sequenceValues.length -1;i++){ 57 | retval += sequenceValues[i].toString().replace("PsidSsp ", "") + ","; 58 | } 59 | if(sequenceValues.length > 0){ 60 | retval += sequenceValues[sequenceValues.length-1].toString().replace("PsidSsp ", ""); 61 | } 62 | } 63 | retval += "]"; 64 | return retval; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/test/groovy/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/basic/LinkageSeedSpec.groovy: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic 14 | 15 | import java.security.MessageDigest 16 | 17 | import org.bouncycastle.util.encoders.Hex; 18 | import org.certificateservices.custom.c2x.common.BaseStructSpec; 19 | import org.certificateservices.custom.c2x.common.crypto.DefaultCryptoManagerParams; 20 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.LinkageSeed; 21 | 22 | import spock.lang.Specification; 23 | import spock.lang.Unroll; 24 | 25 | /** 26 | * Test for LinkageSeed 27 | * 28 | * @author Philip Vendil, p.vendil@cgi.com 29 | * 30 | */ 31 | class LinkageSeedSpec extends BaseStructSpec { 32 | 33 | byte[] linkageSeed = Hex.decode("000102030405060708090a0b0c0d0e0f") 34 | 35 | 36 | 37 | 38 | def "Verify that LinkageSeed stores the data correctly"(){ 39 | when: 40 | LinkageSeed h1 = new LinkageSeed(linkageSeed) 41 | then: 42 | h1.getLinkageSeed() == linkageSeed; // verify the methods returns the same data 43 | h1.getLinkageSeed().length == 16 44 | serializeToHex(h1) == "000102030405060708090a0b0c0d0e0f" 45 | 46 | when: 47 | LinkageSeed h2 = deserializeFromHex(new LinkageSeed(), "000102030405060708090a0b0c0d0e0f") 48 | then: 49 | h2.getLinkageSeed() == linkageSeed 50 | } 51 | 52 | def "Verify toString"(){ 53 | expect: 54 | new LinkageSeed(linkageSeed).toString() == "LinkageSeed [000102030405060708090a0b0c0d0e0f]" 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/validator/EmptyDefaultSSPLookup.java: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * * 3 | * Certificate Service - Car2Car Core * 4 | * * 5 | * This software is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Affero General Public License * 7 | * License as published by the Free Software Foundation; either * 8 | * version 3 of the License, or any later version. * 9 | * * 10 | * See terms of license at gnu.org. * 11 | * * 12 | *************************************************************************/ 13 | package org.certificateservices.custom.c2x.ieee1609dot2.validator; 14 | 15 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.Psid; 16 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.ServiceSpecificPermissions; 17 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.SspRange; 18 | 19 | /** 20 | * Implementation of DefaultSSPLookup that doesn't contain any default values for any SSP or SSPRanges and 21 | * always returns null. Used in PKIs where no default SSP values are defined. 22 | * 23 | * @author Philip Vendil, p.vendil@cgi.com 24 | */ 25 | public class EmptyDefaultSSPLookup implements DefaultSSPLookup { 26 | 27 | /** 28 | * Method that always returns null as default ServiceSpecificPermissions. 29 | * 30 | * @param psid the PSID to lookup default ssp range for. 31 | * @return the default ServiceSpecificPermissions defined for given Psid or null. 32 | */ 33 | @Override 34 | public ServiceSpecificPermissions getDefaultSSP(Psid psid) { 35 | return null; 36 | } 37 | 38 | /** 39 | * Method that always returns null as default SspRange. 40 | * 41 | * @param psid the PSID to lookup default ssp range for. 42 | * @return the default SspRange defined for given psid or null. 43 | */ 44 | @Override 45 | public SspRange getDefaultSSPRange(Psid psid) { 46 | return null; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/certificateservices/custom/c2x/etsits103097/v131/AvailableITSAID.java: -------------------------------------------------------------------------------- 1 | package org.certificateservices.custom.c2x.etsits103097.v131; 2 | 3 | import org.certificateservices.custom.c2x.ieee1609dot2.datastructs.basic.Psid; 4 | 5 | /** 6 | * Contains Defined ITS AID constants according to 102 965 V1.4.1 7 | * 8 | * @author Philip Vendil p.vendil@cgi.com 9 | */ 10 | public class AvailableITSAID { 11 | 12 | /** 13 | * CA basic service is specified in 14 | * ETSI EN 302 637-2 [i.2] 15 | */ 16 | public static Psid CABasicService = new Psid(36); 17 | 18 | /** 19 | * DEN basic service is specified in 20 | * ETSI EN 302 637-3 [i.3] 21 | */ 22 | public static Psid DENBasicService = new Psid(37); 23 | 24 | /** 25 | * TLM service as specified in 26 | * ETSI TS 103 301 [i.4] 27 | */ 28 | public static Psid TLMService = new Psid(137); 29 | 30 | /** 31 | * RLT service as specified in 32 | * ETSI TS 103 301 [i.4] 33 | */ 34 | public static Psid RLTService = new Psid(138); 35 | 36 | /** 37 | * IVI service as specified in 38 | * ETSI TS 103 301 [i.4] 39 | */ 40 | public static Psid IVIService = new Psid(139); 41 | 42 | /** 43 | * TLC service as specified in 44 | * ETSI TS 103 301 [i.4] 45 | */ 46 | public static Psid TLCService = new Psid(140); 47 | 48 | /** 49 | * GeoNetworking Management 50 | * Communications as specified in 51 | * ETSI EN 302 636-4-1 [i.5] 52 | */ 53 | public static Psid GeoNetworkingManagementCommunications = new Psid(141); 54 | 55 | /** 56 | * SA service as specified in 57 | * ETSI EN 302 890-1 [i.6] 58 | */ 59 | public static Psid SAService = new Psid(540801); 60 | 61 | /** 62 | * CRL service as specified in ETSI 63 | * TS 102 941 [i.7] 64 | */ 65 | public static Psid CRLService = new Psid(622); 66 | 67 | /** 68 | * Secure certificate request service 69 | * as specified in ETSI 70 | * TS 102 941 [i.7] 71 | */ 72 | public static Psid SecuredCertificateRequestService = new Psid(623); 73 | 74 | /** 75 | * CTL service as specified in ETSI 76 | * TS 102 941 [i.7] 77 | */ 78 | public static Psid CTLService = new Psid(624); 79 | 80 | /** 81 | * GPC service as specified in 82 | * ETSI TS 103 301 [i.4] 83 | */ 84 | public static Psid GPCService = new Psid(540802); 85 | 86 | } 87 | --------------------------------------------------------------------------------