4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-09-10 21:12:30 +00:00
Files
.github
bridge
ci
contrib
docker
gateway
hook
img
matterclient
matterhook
vendor
github.com
42wim
Philipp15b
go-steam
cryptoutil
cryptoutil.go
ecb.go
pkcs7.go
rsa.go
netutil
protocol
rwu
socialcache
steamid
.gitignore
.gitmodules
LICENSE.txt
README.md
auth.go
auth_events.go
client.go
client_events.go
connection.go
doc.go
gamecoordinator.go
keys.go
notifications.go
notifications_events.go
servers.go
social.go
social_events.go
steam_directory.go
trading.go
trading_events.go
web.go
web_events.go
bwmarrin
davecgh
dfordsoft
dgrijalva
fsnotify
go-telegram-bot-api
golang
google
gorilla
hashicorp
jpillora
kardianos
konsorten
labstack
lrstanley
magiconair
matterbridge
mattermost
mattn
mgutz
mitchellh
mreiferson
mrexodia
nicksnyder
nlopes
paulrosania
pborman
pelletier
peterhellberg
pkg
pmezard
rs
russross
saintfish
shazow
shurcooL
sirupsen
spf13
stretchr
technoweenie
valyala
zfjagann
gitlab.com
go.uber.org
golang.org
gopkg.in
modules.txt
.golangci.yaml
.travis.yml
Dockerfile
LICENSE
README.md
changelog.md
go.mod
go.sum
matterbridge.go
matterbridge.toml.sample
matterbridge.toml.simple
2017-06-22 01:00:27 +02:00

69 lines
1.6 KiB
Go

package cryptoutil
import (
"crypto/cipher"
)
// From this code review: https://codereview.appspot.com/7860047/
// by fasmat for the Go crypto/cipher package
type ecb struct {
b cipher.Block
blockSize int
}
func newECB(b cipher.Block) *ecb {
return &ecb{
b: b,
blockSize: b.BlockSize(),
}
}
type ecbEncrypter ecb
// NewECBEncrypter returns a BlockMode which encrypts in electronic code book
// mode, using the given Block.
func newECBEncrypter(b cipher.Block) cipher.BlockMode {
return (*ecbEncrypter)(newECB(b))
}
func (x *ecbEncrypter) BlockSize() int { return x.blockSize }
func (x *ecbEncrypter) CryptBlocks(dst, src []byte) {
if len(src)%x.blockSize != 0 {
panic("cryptoutil/ecb: input not full blocks")
}
if len(dst) < len(src) {
panic("cryptoutil/ecb: output smaller than input")
}
for len(src) > 0 {
x.b.Encrypt(dst, src[:x.blockSize])
src = src[x.blockSize:]
dst = dst[x.blockSize:]
}
}
type ecbDecrypter ecb
// newECBDecrypter returns a BlockMode which decrypts in electronic code book
// mode, using the given Block.
func newECBDecrypter(b cipher.Block) cipher.BlockMode {
return (*ecbDecrypter)(newECB(b))
}
func (x *ecbDecrypter) BlockSize() int { return x.blockSize }
func (x *ecbDecrypter) CryptBlocks(dst, src []byte) {
if len(src)%x.blockSize != 0 {
panic("cryptoutil/ecb: input not full blocks")
}
if len(dst) < len(src) {
panic("cryptoutil/ecb: output smaller than input")
}
for len(src) > 0 {
x.b.Decrypt(dst, src[:x.blockSize])
src = src[x.blockSize:]
dst = dst[x.blockSize:]
}
}