ddc

package module
v0.8.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 11 Imported by: 0

README

ddc

Golang библиотека для формирования и разбора Карточки электронного документа, разработана для сервиса обмена цифровыми подписями SIGEX.

Так же репозиторий включает в себя пакет rpcsrv, экспортирующий функционал библиотеки через JSON-RPC, и соответствующий сервер rpcsrv/cmd.

Документация: https://pkg.go.dev/github.com/sigex-kz/ddc.

Примеры использования библиотеки доступны в ddc_test.go.

Примеры работы через JSON-RPC доступны в rpcsrv/rpcsrv_test.go.

Сборки JSON-RPC сервера под разные платформы доступны в релизах.

Шаблон файла сервиса для systemd (/etc/systemd/system/ddc.service):

[Unit]
Description=Digital Document Card RPC srv

StartLimitIntervalSec=60s
StartLimitBurst=10

[Service]
Type=simple
User=ddcrunner
WorkingDirectory=/opt/ddc
ExecStart=/opt/ddc/ddcrpcsrv
Restart=always
RestartSec=5s

[Install]
WantedBy=multi-user.target

Лицензия: LICENSE.

Documentation

Overview

Package ddc implements Digital document card specification (https://github.com/kaarkz/ddcard)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractAttachments

func ExtractAttachments(ddcPdf io.ReadSeeker) (documentOriginal *AttachedFile, signatures []AttachedFile, err error)

ExtractAttachments from DDC and return them as structures

Types

type AttachedFile

type AttachedFile struct {
	Name  string
	Bytes []byte
}

AttachedFile information

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder builds Digital Document Card

func NewBuilder

func NewBuilder(di *DocumentInfo) (*Builder, error)

NewBuilder creates a new DDC Builder

func (*Builder) Build

func (ddc *Builder) Build(visualizeDocument, visualizeSignatures bool, creationDate, builderName, howToVerify string, w io.Writer) error

Build DDC and write it's bytes to w

func (*Builder) EmbedDoc added in v0.6.0

func (ddc *Builder) EmbedDoc(doc io.ReadSeeker, fileName string) error

EmbedDoc registers a digital document original in any format that should be embedded into DDC

func (*Builder) EmbedPDF

func (ddc *Builder) EmbedPDF(pdf io.ReadSeeker, fileName string) error

EmbedPDF registers a digital document original in PDF format that should be embedded into DDC

type DocumentInfo

type DocumentInfo struct {
	// Title of the document
	Title string `json:"title"`

	// Optional description of the document
	Description string `json:"description"`

	// Optional id of the document
	ID string `json:"id"`

	// Optional qr code with the id of the document, should be set if id is set
	IDQRCode []byte `json:"idQRCode"`

	// Signatures information
	Signatures []SignatureInfo `json:"signatures"`

	// The language to build DDC in ["ru", "kk", "kk/ru"]
	Language string `json:"language"`
}

DocumentInfo contains information about the digital document and signatures

type SignatureInfo

type SignatureInfo struct {
	// Signature body bytes
	Body []byte `json:"body"`

	// File name for attachment
	FileName string `json:"fileName"`

	// Signer name to build attachment description (optional, required if SignatureVisualization is not provided)
	SignerName string `json:"signerName"`

	// Signature visualization information (optional, required for signatures visualization)
	SignatureVisualization *SignatureVisualization `json:"signatureVisualization"`
}

SignatureInfo used to embed signature in DDC and optionally to construct visualization

type SignatureVisualization

type SignatureVisualization struct {
	// Signers full name
	SubjectName string `json:"subjectName"`

	// Signers identification number such as IIN or passport number
	SubjectID string `json:"subjectID"`

	// In case if the subject signed as an employee, name of the employer
	SubjectOrgName string `json:"subjectOrgName"`

	// In case if the subject signed as an employee, identification number of the employer, such as BIN or tax number
	SubjectOrgID string `json:"subjectOrgID"`

	// Subjects full RDN in RFC 4514 format
	Subject string `json:"subject"`

	// Subjects alternative names from subjectAltName certificate extension
	SubjectAltName string `json:"subjectAltName"`

	// Serial number of the signers certificate
	SerialNumber string `json:"serialNumber"`

	// From value from certificate in format "19.05.2021 04:01:52 UTC+6"
	From string `json:"from"`

	// Until value from certificate in format "19.05.2021 04:01:52 UTC+6"
	Until string `json:"until"`

	// Certificate policies (aka certificate templates) in the following format "Human readable name (OID)"
	Policies []string `json:"policies"`

	// Key usages in the following format "Human readable name (const from https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.3)"
	KeyUsage []string `json:"keyUsage"`

	// Extended key usages in the following format "Human readable name (OID)"
	ExtKeyUsage []string `json:"extKeyUsage"`

	// Certificate issuers full RDN in RFC 4514 format
	Issuer string `json:"issuer"`

	// Signature algorithm in the following format "Human readable name (OID)"
	SignatureAlgorithm string `json:"signatureAlgorithm"`

	// Time stamp imformation
	TSP struct {

		// Time stamp from TSP response in format "19.05.2021 04:01:52 UTC+6"
		// converted to time zone of Nur-Sultan
		GeneratedAt string `json:"generatedAt"`

		// Serial number of the TSP signers certificate
		SerialNumber string `json:"serialNumber"`

		// TSP signers certificate subject full RDN in RFC 4514 format
		Subject string `json:"subject"`

		// TSP signers certificate issuer full RDN in RFC 4514 format
		Issuer string `json:"issuer"`
	} `json:"tsp"`

	// OCSP response information
	OCSP struct {

		// ThisUpdate value from OCSP response in format "19.05.2021 04:01:52 UTC+6"
		// converted to time zone of Nur-Sultan
		GeneratedAt string `json:"generatedAt"`

		// CertStatus from OCSP response as a string (one of "good", "revoked", or "unknown")
		CertStatus string `json:"certStatus"`

		// Serial number of the OCSP signers certificate
		SerialNumber string `json:"serialNumber"`

		// OCSP signers certificate subject full RDN in RFC 4514 format
		Subject string `json:"subject"`

		// OCSP signers certificate issuer full RDN in RFC 4514 format
		Issuer string `json:"issuer"`
	} `json:"ocsp"`

	// Signature body encoded as a sey of QR codes and stored as PNG images (optional)
	QRCodes [][]byte `json:"qrCodes"`
}

SignatureVisualization information used to construct signature visualization page

Directories

Path Synopsis
Package rpcsrv implements a RPC server for ddc library
Package rpcsrv implements a RPC server for ddc library
cmd
Runs ddc RPC server
Runs ddc RPC server

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL