Giter Club home page Giter Club logo

cms's People

Contributors

adapik avatar falseclock avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cms's Issues

Validate structure of Certificate, SignedData

Use a structure (array or json) to describe rfc schema of library objects. Now without validation a lot of checks need to be done for perventing errors in case of malformed data. Validation by schema may also form a structure which can be used in access methods. Sсhema should includes options:

  1. type of object
  2. children elements
  3. optional elements
  4. tagged objects
  5. choice (enum)
  6. set of (sequence of) elements

OCSPRequest

Can you add additional clases to mapping, cause it can be also part of unsiged data?

abstract class OCSPRequest
{
	/*
	    https://tools.ietf.org/html/rfc5280
		OCSPRequest     ::=     SEQUENCE {
			tbsRequest                  TBSRequest,
			optionalSignature   [0]     EXPLICIT Signature OPTIONAL
		}
	*/
	const MAP = [
		'type'     => Identifier::SEQUENCE,
		'children' => [
			'tbsRequest'        => [ 'type' => TBSRequest::MAP ],
			'optionalSignature' => [
				'type'     => Signature::MAP,
				'optional' => true,
				'explicit' => true,
				'constant' => 0,
			],
		],
	];
}

abstract class TBSRequest
{
	/*
		TBSRequest      ::=     SEQUENCE {

		   version             [0]     EXPLICIT Version DEFAULT v1,
		   requestorName       [1]     EXPLICIT GeneralName OPTIONAL,
		   requestList                 SEQUENCE OF Request,
		   requestExtensions   [2]     EXPLICIT Extensions OPTIONAL }

	 */
	const MAP = [
		'type'     => Identifier::SEQUENCE,
		'children' => [
			'version'           => [
				'type'     => Identifier::INTEGER,
				'constant' => 0,
				'optional' => true,
				'explicit' => true,
				'mapping'  => [ 'v1', 'v2', 'v3' ],
				'default'  => 'v1',
			],
			'requestorName'     => [
				'constant' => 1,
				'optional' => true,
				'explicit' => true,
			],
			'requestList'       => [
				'type' => Request::MAP,
			],
			'requestExtensions' => [
									   'constant' => 2,
									   'optional' => true,
									   'explicit' => true,
								   ] + Extensions::MAP,
		],
	];
}

abstract class Request
{
	/**
	 *    Request         ::=     SEQUENCE {
	 *        reqCert                     CertID,
	 *        singleRequestExtensions     [0] EXPLICIT Extensions OPTIONAL
	 *    }
	 */
	const MAP = [
		'type'     => Identifier::SEQUENCE,
		'children' => [
			'reqCert'                 => [ 'type' => CertID::MAP ],
			'singleRequestExtensions' => [
											 'constant' => 0,
											 'optional' => true,
											 'explicit' => true,
										 ] + Extensions::MAP,
		],
	];
}

abstract class CertID
{
	/**
	 *  CertID          ::=     SEQUENCE {
	 *        hashAlgorithm       AlgorithmIdentifier,
	 *        issuerNameHash      OCTET STRING, -- Hash of Issuer's DN
	 *        issuerKeyHash       OCTET STRING, -- Hash of Issuers public key
	 *      serialNumber        CertificateSerialNumber
	 *    }
	 */
	const MAP = [
		'type'     => Identifier::SEQUENCE,
		'children' => [
			'hashAlgorithm'  => [ 'type' => AlgorithmIdentifier::MAP ],
			'issuerNameHash' => [ 'type' => Identifier::OCTETSTRING ],
			'issuerKeyHash'  => [ 'type' => Identifier::OCTETSTRING ],
			'serialNumber'   => [ 'type' => CertificateSerialNumber::MAP ],

		],
	];
}

abstract class Signature
{
	/**
	 * Signature       ::=     SEQUENCE {
	 *        signatureAlgorithm   AlgorithmIdentifier,
	 *        signature            BIT STRING,
	 *        certs                [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL
	 * }
	 */
	const MAP = [
		'type'     => Identifier::SEQUENCE,
		'children' => [
			'signatureAlgorithm' => [ 'type' => AlgorithmIdentifier::MAP ],
			'signature'          => [ 'type' => Identifier::BITSTRING ],
			'certs'              => [
				'type'     => Certificate::MAP,
				'optional' => true,
				'explicit' => true,
				'constant' => 0,
			],

		],
	];
}

How to use?

I need to generate a file signed with CadES.

How can I sign a txt file using this package?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.