/**
 * <p class=proto-main>The common proto is utilized to use common DRM Message.</p>
 * <div class="proto-hier">
 *  <a href="#com.fca.uconnect.global.DRM">DRM</a>
 *  <a href="#com.fca.uconnect.global.DRMSignature">DRMSignature</a>
 *  <a href="#com.fca.uconnect.global.DRMRegistration">DRMRegistration</a>
 * </div>
 *
 * <h3 class="change-log-hdr">Change Log</h3>
 * <table id="change-log" class="change-log">
 *  <thead>
 *   <tr><th>Version</th><th>Date</th><th>Notes</th></tr>
 *  </thead>
 *  <tbody>
 *   <tr><td>1.4</td><td>2018-08-21</td><td>Updated DRM to remove the issuer and signature fields per Feature Architect.</td></tr>
 *   <tr><td>1.4</td><td>2018-05-28</td><td>Updated DRM to fix VP2R support and make it generic.</td></tr>
 *   <tr><td>1.3</td><td>2018-05-14</td><td>Release of DRMSignature and updated DRM</td></tr>
 *   <tr><td>1.2</td><td>2017-11-02</td><td>Added Content Type and Signature support</td></tr>
 *   <tr><td>1.1</td><td>2017-11-02</td><td>Update to Proto3</td></tr>	
 *   <tr><td>1.0</td><td>2017-09-20</td><td>Release of initial Proto</td></tr>
 *  </tbody>
 * </table>
 *
 * <h3>Signature Schema</h3>
 * <pre>RSASSA-PKCS1-v1_5, see RFC8017 "PKCS #1: RSA Cryptography Specifications Version 2.2", section 8.2.
 * 
 * Signature algorithm OID:
 * 
 * pkcs-1 {
 *     iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-1(1)
 * }
 * sha256WithRSAEncryption      OBJECT IDENTIFIER ::= { pkcs-1 11 }
 * 
 * Applicable Key lenght 2048, 3072, 4096 or higher.
 * 
 * RSASSA-PKCS1-V1_5-SIGN (K, M)
 * 
 *       K        signer's RSA private key
 *       M        message to be signed, octet string UTF8(drm.properties)
 * 
 * For UTF8 encoding see rfc3629, "UTF-8, a transformation format of ISO 10646"
 * </pre>
 */
syntax="proto3";
package com.fca.uconnect.global;

message X509Certificates {
	repeated string certificate = 1; /// PEM-encoded X.509 certificate chain
}

message DRMSignature {
	enum SignatureType {
		RSA2048_SHA256_RSASSA_PKCS1_V1_5 = 0; /// RSA 2048 signature with SHA256 digest and signature scheme RSASSA_PKCS1_V1_5
		RSA3072_SHA256_RSASSA_PKCS1_V1_5 = 1; /// RSA 3072 signature with SHA256 digest and signature scheme RSASSA_PKCS1_V1_5
		RSA4096_SHA256_RSASSA_PKCS1_V1_5 = 2; /// RSA 4096 signature with SHA256 digest and signature scheme RSASSA_PKCS1_V1_5
	}

	SignatureType signatureType = 1; /// This defines the type of Signature used to sign the drmFile buffer. Optional fields to be used only when the signature is not a JarSigned file.


	//string issuer = 6;///RFC 5280 (4.1.2.4) The issuer field identifies the entity that has signed and issued the certificate. The issuer of the certificate, that shall be used to verify the DRM.
	//bytes serialNumber = 7; /// The Serial Number of the Certificate that shall be used to verify the DRM
	bytes signature = 4; /// signature = drm.signature
	X509Certificates x509Certificates = 5; /// X.509 Certificate chain, where the first certificate is the one that shall be used to verify the signature and the last one is root of the DRM subtree.
}

message DRM { /// Upload the DRM File using this message
	enum ContentTypes {
		GENERIC = 0; /// File Contents intended for any generic ECU
		JVM = 1; /// File contents intended for JAVA based systems
		APK = 2; /// File contents intended for Android based systems
	}
	ContentTypes contentType = 3; /// Defines the type of DRM content type.
	bytes drmFile = 1; /// The content of the drmFile shall be serialized in the following way: drmFile = BASE64(UTF8(drm.properties)). This contain the base64 encoded DRM file contents to support sending a file for features and services. drmFile = BASE64(UTF8(drm.properties)) or drmFile = BASE64(drm.jar)
	DRMSignature drmSignature = 2; /// info to choose the right certificate from ecu certificate store
}

message DRMRegistration { /// Not currently used
	RegistrationStatusEnum registrationStatus = 1; /// This contains Uconnect Access registration status of the VIN the TU it is installed on.
	OperationEnum operation = 2; /// This indicates which stage of registration has been performed for VIN.
	int64 basicRegExpiryTimeStamp = 3; /// This indicates the expiration date of the user initiated basic registration date, displayed in millisecond values.
	enum OperationEnum {
		NOOP = 0; /// Indicates there is no operation to be executed by the device.
		RESET = 1; /// Indicates the device shall be reset which involves disconnecting and re-connecting to the SDP.
		RETURN_TO_NEW = 2; /// Indicates the device shall be reset and cleared of user configuration data.
	}
	enum RegistrationStatusEnum {
		NOT_REGISTERED = 0; /// The user has not registered this vehicle with a Uconnect Account.
		BASIC_STAGE = 1; /// When the user requested the registration email, but has not yet completed the registration process.
		FULL_STAGE = 2; /// User has completed registration, but did not have a wallet account setup.
		COMPLETE_STAGE = 3; /// Final stage where the user has a wallet configured to allow purchasing of services.
	}

	string accountDN = 7; /// accountDN number of the TU being registered
	int64 expireTime = 8; /// The service being provisioned/activated is considered active from the time this message is received until the expire time, expressed in milliseconds elapsed since 1 January 1970 00:00:00 UTC.
	int32 fileLength = 9; /// file length in bytes
	int32 fileChecksum = 10; /// filechecksum information
	// string featureMask = 11; /// DRM Feature Mask
	int64 expireTimeSpanBegin = 12;/// DRM expiration time start
	int64 expireTimeSpanEnd = 13; /// DRM expiration time end
	string emailId = 14; /// emailID if needed
}
