classic

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: Apache-2.0, MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AES_KEY_SIZE   = 128 / 8
	AES_BLOCK_SIZE = 128 / 8

	// AES-ECB
	AES_PLAINTEXT_BUFFER_LENGTH  = 256
	AES_CIPHERTEXT_BUFFER_LENGTH = 256 + 16 + 2
	AES_SYMMETRICKEY_LENGTH      = framework.ALGORYTHM_CODE_SIZE + framework.KEY_TYPE_BYTES + AES_KEY_SIZE
)
View Source
var (
	ED25519_ALGORITHM   = framework.DefineSignature("ED25519", false, 21)
	ECDSA_ALGORITHM     = framework.DefineSignature("ECDSA", false, 22)
	RSA_ALGORITHM       = framework.DefineSignature("RSA", true, 23)
	SHA256_ALGORITHM    = framework.DefineHash("SHA256", 24)
	RIPEMD160_ALGORITHM = framework.DefineHash("RIPEMD160", 25)
	AES_ALGORITHM       = framework.DefineSymmetricEncryption("AES", 26)
	GO_RANDOM_ALGORITHM = framework.DefineRandom("GO-RANDOM", 27)
)
View Source
var (
	ECDSA_PUBKEY_SIZE            = 65
	ECDSA_PRIVKEY_SIZE           = 32
	ECDSA_SIGNATUREDIGEST_SIZE   = 64
	ECDSA_PUBKEY_LENGTH          = framework.ALGORYTHM_CODE_SIZE + framework.KEY_TYPE_BYTES + ECDSA_PUBKEY_SIZE
	ECDSA_PRIVKEY_LENGTH         = framework.ALGORYTHM_CODE_SIZE + framework.KEY_TYPE_BYTES + ECDSA_PRIVKEY_SIZE
	ECDSA_SIGNATUREDIGEST_LENGTH = framework.ALGORYTHM_CODE_SIZE + ECDSA_SIGNATUREDIGEST_SIZE
)
View Source
var (
	ED25519_PUBKEY_SIZE            = 32
	ED25519_PRIVKEY_SIZE           = 32
	ED25519_SIGNATUREDIGEST_SIZE   = 64
	ED25519_PUBKEY_LENGTH          = framework.ALGORYTHM_CODE_SIZE + framework.KEY_TYPE_BYTES + ED25519_PUBKEY_SIZE
	ED25519_PRIVKEY_LENGTH         = framework.ALGORYTHM_CODE_SIZE + framework.KEY_TYPE_BYTES + ED25519_PRIVKEY_SIZE
	ED25519_SIGNATUREDIGEST_LENGTH = framework.ALGORYTHM_CODE_SIZE + ED25519_SIGNATUREDIGEST_SIZE
)
View Source
var (
	RIPEMD160_DIGEST_BYTES  = 160 / 8
	RIPEMD160_DIGEST_LENGTH = framework.ALGORYTHM_CODE_SIZE + RIPEMD160_DIGEST_BYTES
)
View Source
var (
	// modulus.length = 256, publicExponent.length = 3
	RSA_PUBKEY_SIZE = 259
	// modulus.length = 256, publicExponent.length = 3, privateExponent.length = 256, p.length = 128, q.length =128,
	// dP.length = 128, dQ.length = 128, qInv.length = 128
	RSA_PRIVKEY_SIZE = 1155

	RSA_SIGNATUREDIGEST_SIZE = 256
	RSA_CIPHERTEXTBLOCK_SIZE = 256

	RSA_PUBKEY_LENGTH          = framework.ALGORYTHM_CODE_SIZE + framework.KEY_TYPE_BYTES + RSA_PUBKEY_SIZE
	RSA_PRIVKEY_LENGTH         = framework.ALGORYTHM_CODE_SIZE + framework.KEY_TYPE_BYTES + RSA_PRIVKEY_SIZE
	RSA_SIGNATUREDIGEST_LENGTH = framework.ALGORYTHM_CODE_SIZE + RSA_SIGNATUREDIGEST_SIZE
)
View Source
var SHA256_DIGEST_BYTES = 256 / 8

Functions

This section is empty.

Types

type AESEncryptionFunction

type AESEncryptionFunction struct {
}

func (AESEncryptionFunction) Decrypt

func (AESEncryptionFunction) Encrypt

func (AESEncryptionFunction) GenerateSymmetricKey

func (A AESEncryptionFunction) GenerateSymmetricKey() *framework.SymmetricKey

func (AESEncryptionFunction) GetAlgorithm

func (AESEncryptionFunction) ParseCiphertext

func (A AESEncryptionFunction) ParseCiphertext(ciphertextBytes []byte) (*framework.SymmetricCiphertext, error)

func (AESEncryptionFunction) ParseSymmetricKey

func (A AESEncryptionFunction) ParseSymmetricKey(symmetricKeyBytes []byte) (*framework.SymmetricKey, error)

func (AESEncryptionFunction) SupportCiphertext

func (A AESEncryptionFunction) SupportCiphertext(ciphertextBytes []byte) bool

func (AESEncryptionFunction) SupportSymmetricKey

func (A AESEncryptionFunction) SupportSymmetricKey(symmetricKeyBytes []byte) bool

type ClassicCryptoService

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

func NewClassicCryptoService

func NewClassicCryptoService() ClassicCryptoService

func (ClassicCryptoService) GetFunctions

func (c ClassicCryptoService) GetFunctions() []framework.CryptoFunction

type ECDSASignatureFunction

type ECDSASignatureFunction struct {
}

func (ECDSASignatureFunction) GenerateKeypair

func (E ECDSASignatureFunction) GenerateKeypair() (*framework.AsymmetricKeypair, error)

func (ECDSASignatureFunction) GenerateKeypairWithSeed

func (E ECDSASignatureFunction) GenerateKeypairWithSeed(seed []byte) (keypair *framework.AsymmetricKeypair, err error)

func (ECDSASignatureFunction) GetAlgorithm

func (ECDSASignatureFunction) ParseDigest

func (E ECDSASignatureFunction) ParseDigest(digestBytes []byte) (*framework.SignatureDigest, error)

func (ECDSASignatureFunction) ParsePrivKey

func (E ECDSASignatureFunction) ParsePrivKey(privKeyBytes []byte) (*framework.PrivKey, error)

func (ECDSASignatureFunction) ParsePubKey

func (E ECDSASignatureFunction) ParsePubKey(pubKeyBytes []byte) (*framework.PubKey, error)

func (ECDSASignatureFunction) RetrieveEncrypedPrivKey added in v1.3.0

func (E ECDSASignatureFunction) RetrieveEncrypedPrivKey(privateKey string, pwd []byte) (*framework.PrivKey, error)

func (ECDSASignatureFunction) RetrievePrivKey added in v1.3.0

func (E ECDSASignatureFunction) RetrievePrivKey(privateKey string) (*framework.PrivKey, error)

func (ECDSASignatureFunction) RetrievePubKey

func (E ECDSASignatureFunction) RetrievePubKey(privKey *framework.PrivKey) (*framework.PubKey, error)

func (ECDSASignatureFunction) RetrievePubKeyFromCA added in v1.3.0

func (E ECDSASignatureFunction) RetrievePubKeyFromCA(cert *ca.Certificate) (*framework.PubKey, error)

func (ECDSASignatureFunction) Sign

func (ECDSASignatureFunction) SupportDigest

func (E ECDSASignatureFunction) SupportDigest(digestBytes []byte) bool

func (ECDSASignatureFunction) SupportPrivKey

func (E ECDSASignatureFunction) SupportPrivKey(privKeyBytes []byte) bool

func (ECDSASignatureFunction) SupportPubKey

func (E ECDSASignatureFunction) SupportPubKey(pubKeyBytes []byte) bool

func (ECDSASignatureFunction) Verify

func (E ECDSASignatureFunction) Verify(pubKey *framework.PubKey, data []byte, digest *framework.SignatureDigest) bool

type ED25519SignatureFunction

type ED25519SignatureFunction struct {
}

func (ED25519SignatureFunction) GenerateKeypair

func (ED25519SignatureFunction) GenerateKeypairWithSeed

func (E ED25519SignatureFunction) GenerateKeypairWithSeed(seed []byte) (keypair *framework.AsymmetricKeypair, err error)

func (ED25519SignatureFunction) GetAlgorithm

func (ED25519SignatureFunction) ParseDigest

func (E ED25519SignatureFunction) ParseDigest(digestBytes []byte) (*framework.SignatureDigest, error)

func (ED25519SignatureFunction) ParsePrivKey

func (E ED25519SignatureFunction) ParsePrivKey(privKeyBytes []byte) (*framework.PrivKey, error)

func (ED25519SignatureFunction) ParsePubKey

func (E ED25519SignatureFunction) ParsePubKey(pubKeyBytes []byte) (*framework.PubKey, error)

func (ED25519SignatureFunction) RetrieveEncrypedPrivKey added in v1.3.0

func (E ED25519SignatureFunction) RetrieveEncrypedPrivKey(privateKey string, pwd []byte) (*framework.PrivKey, error)

func (ED25519SignatureFunction) RetrievePrivKey added in v1.3.0

func (E ED25519SignatureFunction) RetrievePrivKey(privateKey string) (*framework.PrivKey, error)

func (ED25519SignatureFunction) RetrievePubKey

func (E ED25519SignatureFunction) RetrievePubKey(privKey *framework.PrivKey) (*framework.PubKey, error)

func (ED25519SignatureFunction) RetrievePubKeyFromCA added in v1.3.0

func (E ED25519SignatureFunction) RetrievePubKeyFromCA(cert *ca.Certificate) (*framework.PubKey, error)

func (ED25519SignatureFunction) Sign

func (ED25519SignatureFunction) SupportDigest

func (E ED25519SignatureFunction) SupportDigest(digestBytes []byte) bool

func (ED25519SignatureFunction) SupportPrivKey

func (E ED25519SignatureFunction) SupportPrivKey(privKeyBytes []byte) bool

func (ED25519SignatureFunction) SupportPubKey

func (E ED25519SignatureFunction) SupportPubKey(pubKeyBytes []byte) bool

func (ED25519SignatureFunction) Verify

func (E ED25519SignatureFunction) Verify(pubKey *framework.PubKey, data []byte, digest *framework.SignatureDigest) bool

type GoRandomFunction

type GoRandomFunction struct {
}

func (GoRandomFunction) Generate

func (GoRandomFunction) GetAlgorithm

func (g GoRandomFunction) GetAlgorithm() framework.CryptoAlgorithm

type GoRandomGenerator

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

func (GoRandomGenerator) NextBytes

func (g GoRandomGenerator) NextBytes(size int) []byte

type RIPEMD160HashFunction

type RIPEMD160HashFunction struct {
}

func (RIPEMD160HashFunction) GetAlgorithm

func (RIPEMD160HashFunction) Hash

func (RIPEMD160HashFunction) ParseHashDigest

func (R RIPEMD160HashFunction) ParseHashDigest(digestBytes []byte) (*framework.HashDigest, error)

func (RIPEMD160HashFunction) SupportHashDigest

func (R RIPEMD160HashFunction) SupportHashDigest(digestBytes []byte) bool

func (RIPEMD160HashFunction) Verify

func (R RIPEMD160HashFunction) Verify(digest *framework.HashDigest, data []byte) bool

type RSACryptoFunction

type RSACryptoFunction struct {
}

func (RSACryptoFunction) Decrypt

func (R RSACryptoFunction) Decrypt(privKey *framework.PrivKey, ciphertext *framework.AsymmetricCiphertext) ([]byte, error)

func (RSACryptoFunction) Encrypt

func (RSACryptoFunction) GenerateKeypair

func (R RSACryptoFunction) GenerateKeypair() (*framework.AsymmetricKeypair, error)

func (RSACryptoFunction) GenerateKeypairWithSeed

func (R RSACryptoFunction) GenerateKeypairWithSeed(seed []byte) (keypair *framework.AsymmetricKeypair, err error)

func (RSACryptoFunction) GetAlgorithm

func (R RSACryptoFunction) GetAlgorithm() framework.CryptoAlgorithm

func (RSACryptoFunction) ParseCiphertext

func (R RSACryptoFunction) ParseCiphertext(ciphertextBytes []byte) (*framework.AsymmetricCiphertext, error)

func (RSACryptoFunction) ParseDigest

func (R RSACryptoFunction) ParseDigest(digestBytes []byte) (*framework.SignatureDigest, error)

func (RSACryptoFunction) ParsePrivKey

func (R RSACryptoFunction) ParsePrivKey(privKeyBytes []byte) (*framework.PrivKey, error)

func (RSACryptoFunction) ParsePubKey

func (R RSACryptoFunction) ParsePubKey(pubKeyBytes []byte) (*framework.PubKey, error)

func (RSACryptoFunction) RetrieveEncrypedPrivKey added in v1.3.0

func (R RSACryptoFunction) RetrieveEncrypedPrivKey(privateKey string, pwd []byte) (*framework.PrivKey, error)

func (RSACryptoFunction) RetrievePrivKey added in v1.3.0

func (R RSACryptoFunction) RetrievePrivKey(privateKey string) (*framework.PrivKey, error)

func (RSACryptoFunction) RetrievePubKey

func (R RSACryptoFunction) RetrievePubKey(privKey *framework.PrivKey) (*framework.PubKey, error)

func (RSACryptoFunction) RetrievePubKeyFromCA added in v1.3.0

func (R RSACryptoFunction) RetrievePubKeyFromCA(cert *ca.Certificate) (*framework.PubKey, error)

func (RSACryptoFunction) Sign

func (R RSACryptoFunction) Sign(privKey *framework.PrivKey, data []byte) (*framework.SignatureDigest, error)

func (RSACryptoFunction) SupportCiphertext

func (R RSACryptoFunction) SupportCiphertext(ciphertextBytes []byte) bool

func (RSACryptoFunction) SupportDigest

func (R RSACryptoFunction) SupportDigest(digestBytes []byte) bool

func (RSACryptoFunction) SupportPrivKey

func (R RSACryptoFunction) SupportPrivKey(privKeyBytes []byte) bool

func (RSACryptoFunction) SupportPubKey

func (R RSACryptoFunction) SupportPubKey(pubKeyBytes []byte) bool

func (RSACryptoFunction) Verify

func (R RSACryptoFunction) Verify(pubKey *framework.PubKey, data []byte, digest *framework.SignatureDigest) bool

type SHA256HashFunction

type SHA256HashFunction struct {
}

func (SHA256HashFunction) GetAlgorithm

func (S SHA256HashFunction) GetAlgorithm() framework.CryptoAlgorithm

func (SHA256HashFunction) Hash

func (S SHA256HashFunction) Hash(data []byte) *framework.HashDigest

func (SHA256HashFunction) ParseHashDigest

func (S SHA256HashFunction) ParseHashDigest(digestBytes []byte) (*framework.HashDigest, error)

func (SHA256HashFunction) SupportHashDigest

func (S SHA256HashFunction) SupportHashDigest(digestBytes []byte) bool

func (SHA256HashFunction) Verify

func (S SHA256HashFunction) Verify(digest *framework.HashDigest, data []byte) bool

Jump to

Keyboard shortcuts

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