Sha256: 727446b0f5650a2d5c0513099ae4240fee1bd7f1110dd4cea40c37d5cd977d89

Contents?: true

Size: 1.33 KB

Versions: 16

Compression:

Stored size: 1.33 KB

Contents

// Package aes contains provides AES Key Wrap and ECB mode implementations
package aes

import (
	"crypto/cipher"
)

type ecb struct {
	b cipher.Block
}

type ecbEncrypter ecb
type ecbDecrypter ecb

// NewECBEncrypter creates BlockMode for AES encryption in ECB mode
func NewECBEncrypter(b cipher.Block) cipher.BlockMode {
	return &ecbEncrypter{b: b}
}

// NewECBDecrypter creates BlockMode for AES decryption in ECB mode
func NewECBDecrypter(b cipher.Block) cipher.BlockMode {
	return &ecbDecrypter{b: b}
}

func (x *ecbEncrypter) BlockSize() int { return x.b.BlockSize() }
func (x *ecbDecrypter) BlockSize() int { return x.b.BlockSize() }

func (x *ecbDecrypter) CryptBlocks(dst, src []byte) {
	bs := x.BlockSize()

	if len(src)%bs != 0 {
		panic("ecbDecrypter.CryptBlocks(): input not full blocks")
	}

	if len(dst) < len(src) {
		panic("ecbDecrypter.CryptBlocks(): output smaller than input")
	}

	if len(src) == 0 {
		return
	}

	for len(src) > 0 {
		x.b.Decrypt(dst, src)
		src = src[bs:]
	}
}

func (x *ecbEncrypter) CryptBlocks(dst, src []byte) {
	bs := x.BlockSize()

	if len(src)%bs != 0 {
		panic("ecbEncrypter.CryptBlocks(): input not full blocks")
	}

	if len(dst) < len(src) {
		panic("ecbEncrypter.CryptBlocks(): output smaller than input")
	}

	if len(src) == 0 {
		return
	}

	for len(src) > 0 {
		x.b.Encrypt(dst, src)
		src = src[bs:]
	}
}

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ruby_snowflake_client-1.3.7 ext/vendor/github.com/dvsekhvalnov/jose2go/aes/ecb.go
ruby_snowflake_client-1.3.6 ext/vendor/github.com/dvsekhvalnov/jose2go/aes/ecb.go
ruby_snowflake_client-1.3.5 ext/vendor/github.com/dvsekhvalnov/jose2go/aes/ecb.go
ruby_snowflake_client-1.3.4 ext/vendor/github.com/dvsekhvalnov/jose2go/aes/ecb.go
ruby_snowflake_client-1.3.4.pre.debug ext/vendor/github.com/dvsekhvalnov/jose2go/aes/ecb.go
ruby_snowflake_client-1.3.3.pre.debug ext/vendor/github.com/dvsekhvalnov/jose2go/aes/ecb.go
ruby_snowflake_client-1.3.2 ext/vendor/github.com/dvsekhvalnov/jose2go/aes/ecb.go
ruby_snowflake_client-1.3.1 ext/vendor/github.com/dvsekhvalnov/jose2go/aes/ecb.go
ruby_snowflake_client-1.3.0 ext/vendor/github.com/dvsekhvalnov/jose2go/aes/ecb.go
ruby_snowflake_client-1.2.1 ext/vendor/github.com/dvsekhvalnov/jose2go/aes/ecb.go
ruby_snowflake_client-1.2.0 ext/vendor/github.com/dvsekhvalnov/jose2go/aes/ecb.go
ruby_snowflake_client-1.1.1 ext/vendor/github.com/dvsekhvalnov/jose2go/aes/ecb.go
ruby_snowflake_client-1.1.0 ext/vendor/github.com/dvsekhvalnov/jose2go/aes/ecb.go
ruby_snowflake_client-1.0.2 ext/vendor/github.com/dvsekhvalnov/jose2go/aes/ecb.go
ruby_snowflake_client-1.0.1 ext/vendor/github.com/dvsekhvalnov/jose2go/aes/ecb.go
ruby_snowflake_client-1.0.0 ext/vendor/github.com/dvsekhvalnov/jose2go/aes/ecb.go