mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-09-10 23:32:30 +00:00
.github
bridge
ci
contrib
docker
gateway
hook
matterclient
matterhook
vendor
github.com
42wim
BurntSushi
GeertJohan
Philipp15b
go-steam
community
cryptoutil
cryptoutil.go
ecb.go
pkcs7.go
rsa.go
dota
economy
generator
gsbot
jsont
netutil
protocol
rwu
socialcache
steamid
tf2
trade
tradeoffer
LICENSE.txt
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
alecthomas
bwmarrin
daaku
davecgh
dgrijalva
facebookgo
go-telegram-bot-api
golang
google
gorilla
hashicorp
jpillora
kardianos
labstack
lrstanley
matrix-org
matterbridge
mattermost
mattn
mgutz
mreiferson
mrexodia
nicksnyder
nlopes
paulrosania
pborman
peterhellberg
russross
saintfish
satori
shazow
shurcooL
sirupsen
sorcix
stretchr
technoweenie
tylerb
valyala
x-cray
zfjagann
golang.org
gopkg.in
manifest
.travis.yml
Dockerfile
LICENSE
README.md
changelog.md
matterbridge.go
matterbridge.toml.sample
matterbridge.toml.simple
26 lines
627 B
Go
26 lines
627 B
Go
package cryptoutil
|
|
|
|
import (
|
|
"crypto/aes"
|
|
)
|
|
|
|
// Returns a new byte array padded with PKCS7 and prepended
|
|
// with empty space of the AES block size (16 bytes) for the IV.
|
|
func padPKCS7WithIV(src []byte) []byte {
|
|
missing := aes.BlockSize - (len(src) % aes.BlockSize)
|
|
newSize := len(src) + aes.BlockSize + missing
|
|
dest := make([]byte, newSize, newSize)
|
|
copy(dest[aes.BlockSize:], src)
|
|
|
|
padding := byte(missing)
|
|
for i := newSize - missing; i < newSize; i++ {
|
|
dest[i] = padding
|
|
}
|
|
return dest
|
|
}
|
|
|
|
func unpadPKCS7(src []byte) []byte {
|
|
padLen := src[len(src)-1]
|
|
return src[:len(src)-int(padLen)]
|
|
}
|