kcdsa

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package kcdsa implements the KCDSA(Korean Certificate-based Digital Signature Algorithm) as defined in TTAK.KO-12.0001/R4

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKey

func GenerateKey(priv *PrivateKey, rand io.Reader) error

func GenerateKeyWithSeed added in v1.3.0

func GenerateKeyWithSeed(priv *PrivateKey, rand io.Reader, xkey, upri []byte, sizes ParameterSizes) (xkeyOut, upriOut []byte, err error)

func GenerateParameters

func GenerateParameters(params *Parameters, rand io.Reader, sizes ParameterSizes) (err error)

Generate the parameters without Key Generation Parameters (J, Seed, Count)

func GenerateParametersTTAK

func GenerateParametersTTAK(params *Parameters, rand io.Reader, sizes ParameterSizes) (err error)

Generate the parameters using Key Generation Parameters (J, Seed, Count)

func RegenerateParameters added in v1.3.0

func RegenerateParameters(params *Parameters, rand io.Reader, sizes ParameterSizes) error

TTAKParameters -> P, Q, G(randomly)

func Sign

func Sign(rand io.Reader, priv *PrivateKey, sizes ParameterSizes, data []byte) (r, s *big.Int, err error)

func SignASN1 added in v1.3.0

func SignASN1(rand io.Reader, priv *PrivateKey, sizes ParameterSizes, data []byte) (sig []byte, err error)

Sign data using K generated randomly like in crypto/ecdsa packages. returns the ASN.1 encoded signature.

func Verify

func Verify(pub *PublicKey, sizes ParameterSizes, data []byte, R, S *big.Int) bool

func VerifyASN1 added in v1.3.0

func VerifyASN1(pub *PublicKey, sizes ParameterSizes, data []byte, sig []byte) bool

VerifyASN1 verifies the ASN.1 encoded signature, sig, M, of hash using the public key, pub. Its return value records whether the signature is valid.

Types

type GenerationParameters added in v1.3.0

type GenerationParameters struct {
	J     *big.Int
	Seed  []byte
	Count int
}

func (*GenerationParameters) Equal added in v1.3.0

Equal reports whether p, q, g and sizes have the same value.

func (*GenerationParameters) IsValid added in v1.3.0

func (params *GenerationParameters) IsValid() bool

type ParameterSizes

type ParameterSizes int
const (
	A2048B224SHA224 ParameterSizes = kcdsainternal.A2048B224SHA224 // len(P) = 2048, len(Q) = 224, SHA-224, Recommended
	A2048B224SHA256 ParameterSizes = kcdsainternal.A2048B224SHA256 // len(P) = 2048, len(Q) = 256, SHA-256
	A2048B256SHA256 ParameterSizes = kcdsainternal.A2048B256SHA256 // len(P) = 2048, len(Q) = 256, SHA-256
	A3072B256SHA256 ParameterSizes = kcdsainternal.A3072B256SHA256 // len(P) = 3072, len(Q) = 256, SHA-256, Recommended
	A1024B160HAS160 ParameterSizes = kcdsainternal.A1024B160HAS160 // Deprecated: unsafe. lagacy use only
)
const (
	L2048N224SHA224 ParameterSizes = kcdsainternal.A2048B224SHA224 // Deprecated: use A2048B224SHA224
	L2048N224SHA256 ParameterSizes = kcdsainternal.A2048B224SHA256 // Deprecated: use A2048B224SHA256
	L2048N256SHA256 ParameterSizes = kcdsainternal.A2048B256SHA256 // Deprecated: use A2048B256SHA256
	L3072N256SHA256 ParameterSizes = kcdsainternal.A3072B256SHA256 // Deprecated: use A3072B256SHA256
)

func (ParameterSizes) Hash added in v1.3.0

func (ps ParameterSizes) Hash() hash.Hash

type Parameters

type Parameters struct {
	P, Q, G *big.Int

	GenParameters GenerationParameters
}

func (Parameters) Equal added in v1.3.0

func (params Parameters) Equal(xx Parameters) bool

Equal reports whether p, q, g and sizes have the same value.

type PrivateKey

type PrivateKey struct {
	PublicKey
	X *big.Int
}

PrivateKey represents a KCDSA private key.

func FromDSA added in v1.3.0

func FromDSA(dpk *dsa.PrivateKey) *PrivateKey

func (*PrivateKey) Equal added in v1.3.0

func (priv *PrivateKey) Equal(x crypto.PrivateKey) bool

Equal reports whether priv and x have the same value.

func (*PrivateKey) Public added in v1.3.0

func (priv *PrivateKey) Public() crypto.PublicKey

Public returns the public key corresponding to priv.

func (*PrivateKey) Sign added in v1.3.0

func (priv *PrivateKey) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error)

crypto.Signer

func (*PrivateKey) ToDSA added in v1.3.0

func (kpk *PrivateKey) ToDSA() *dsa.PrivateKey

type PublicKey

type PublicKey struct {
	Parameters
	Y *big.Int
}

PublicKey represents a KCDSA public key.

func (*PublicKey) Equal added in v1.3.0

func (pub *PublicKey) Equal(x crypto.PublicKey) bool

Equal reports whether pub and y have the same value.

type SignerOpts added in v1.3.0

type SignerOpts struct {
	Sizes ParameterSizes
}

SignerOpts contains options for creating and verifying EC-KCDSA signatures.

func (*SignerOpts) HashFunc added in v1.3.0

func (opts *SignerOpts) HashFunc() crypto.Hash

HashFunc returns opts.Hash so that SignerOpts implements crypto.SignerOpts.

Jump to

Keyboard shortcuts

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