code
stringlengths 11
335k
| docstring
stringlengths 20
11.8k
| func_name
stringlengths 1
100
| language
stringclasses 1
value | repo
stringclasses 245
values | path
stringlengths 4
144
| url
stringlengths 43
214
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
func (c *curve25519) UnmarshalBytePoint(point []byte) []byte {
if len(point) != x25519lib.Size+1 {
return nil
}
// Remove prefix
return point[1:]
} | UnmarshalBytePoint decodes the public point to native format, removing the prefix.
See https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-crypto-refresh-06#section-5.5.5.6 | UnmarshalBytePoint | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/curve25519.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/curve25519.go | MIT |
func (c *curve25519) MarshalByteSecret(secret []byte) []byte {
d := make([]byte, x25519lib.Size)
copyReversed(d, secret)
// The following ensures that the private key is a number of the form
// 2^{254} + 8 * [0, 2^{251}), in order to avoid the small subgroup of
// the curve.
//
// This masking is done internally in the underlying lib and so is unnecessary
// for security, but OpenPGP implementations require that private keys be
// pre-masked.
d[0] &= 127
d[0] |= 64
d[31] &= 248
return d
} | MarshalByteSecret encodes the secret scalar from native format.
Note that the EC secret scalar differs from the definition of public keys in
[Curve25519] in two ways: (1) the byte-ordering is big-endian, which is
more uniform with how big integers are represented in OpenPGP, and (2) the
leading zeros are truncated.
See https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-crypto-refresh-06#section-5.5.5.6.1.1
Note that leading zero bytes are stripped later when encoding as an MPI. | MarshalByteSecret | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/curve25519.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/curve25519.go | MIT |
func (c *curve25519) UnmarshalByteSecret(d []byte) []byte {
if len(d) > x25519lib.Size {
return nil
}
// Ensure truncated leading bytes are re-added
secret := make([]byte, x25519lib.Size)
copyReversed(secret, d)
return secret
} | UnmarshalByteSecret decodes the secret scalar from native format.
Note that the EC secret scalar differs from the definition of public keys in
[Curve25519] in two ways: (1) the byte-ordering is big-endian, which is
more uniform with how big integers are represented in OpenPGP, and (2) the
leading zeros are truncated.
See https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-crypto-refresh-06#section-5.5.5.6.1.1 | UnmarshalByteSecret | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/curve25519.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/curve25519.go | MIT |
func (c *curve25519) generateKeyPairBytes(rand io.Reader) (priv, pub x25519lib.Key, err error) {
_, err = io.ReadFull(rand, priv[:])
if err != nil {
return
}
x25519lib.KeyGen(&pub, &priv)
return
} | generateKeyPairBytes Generates a private-public key-pair.
'priv' is a private key; a little-endian scalar belonging to the set
2^{254} + 8 * [0, 2^{251}), in order to avoid the small subgroup of the
curve. 'pub' is simply 'priv' * G where G is the base point.
See https://cr.yp.to/ecdh.html and RFC7748, sec 5. | generateKeyPairBytes | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/curve25519.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/curve25519.go | MIT |
func (c *ed25519) MarshalBytePoint(x []byte) []byte {
return append([]byte{0x40}, x...)
} | MarshalBytePoint encodes the public point from native format, adding the prefix.
See https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-crypto-refresh-06#section-5.5.5.5 | MarshalBytePoint | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/ed25519.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/ed25519.go | MIT |
func (c *ed25519) UnmarshalBytePoint(point []byte) (x []byte) {
if len(point) != ed25519lib.PublicKeySize+1 {
return nil
}
// Return unprefixed
return point[1:]
} | UnmarshalBytePoint decodes a point from prefixed format to native.
See https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-crypto-refresh-06#section-5.5.5.5 | UnmarshalBytePoint | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/ed25519.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/ed25519.go | MIT |
func (c *ed25519) MarshalByteSecret(d []byte) []byte {
return d
} | MarshalByteSecret encodes a scalar in native format.
See https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-crypto-refresh-06#section-5.5.5.5 | MarshalByteSecret | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/ed25519.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/ed25519.go | MIT |
func (c *ed25519) UnmarshalByteSecret(s []byte) (d []byte) {
if len(s) > ed25519lib.SeedSize {
return nil
}
// Handle stripped leading zeroes
d = make([]byte, ed25519lib.SeedSize)
copy(d[ed25519lib.SeedSize-len(s):], s)
return
} | UnmarshalByteSecret decodes a scalar in native format and re-adds the stripped leading zeroes
See https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-crypto-refresh-06#section-5.5.5.5 | UnmarshalByteSecret | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/ed25519.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/ed25519.go | MIT |
func (c *ed25519) MarshalSignature(sig []byte) (r, s []byte) {
return sig[:ed25519Size], sig[ed25519Size:]
} | MarshalSignature splits a signature in R and S.
See https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-crypto-refresh-06#section-5.2.3.3.1 | MarshalSignature | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/ed25519.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/ed25519.go | MIT |
func (c *ed25519) UnmarshalSignature(r, s []byte) (sig []byte) {
// Check size
if len(r) > 32 || len(s) > 32 {
return nil
}
sig = make([]byte, ed25519lib.SignatureSize)
// Handle stripped leading zeroes
copy(sig[ed25519Size-len(r):ed25519Size], r)
copy(sig[ed25519lib.SignatureSize-len(s):], s)
return sig
} | UnmarshalSignature decodes R and S in the native format, re-adding the stripped leading zeroes
See https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-crypto-refresh-06#section-5.2.3.3.1 | UnmarshalSignature | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/ed25519.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/ed25519.go | MIT |
func (c *x448) MarshalBytePoint(point []byte) []byte {
return append([]byte{0x40}, point...)
} | MarshalBytePoint encodes the public point from native format, adding the prefix.
See https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-crypto-refresh-06#section-5.5.5.6 | MarshalBytePoint | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/x448.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/x448.go | MIT |
func (c *x448) UnmarshalBytePoint(point []byte) []byte {
if len(point) != x448lib.Size+1 {
return nil
}
return point[1:]
} | UnmarshalBytePoint decodes a point from prefixed format to native.
See https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-crypto-refresh-06#section-5.5.5.6 | UnmarshalBytePoint | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/x448.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/x448.go | MIT |
func (c *x448) MarshalByteSecret(d []byte) []byte {
return append([]byte{0x40}, d...)
} | MarshalByteSecret encoded a scalar from native format to prefixed.
See https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-crypto-refresh-06#section-5.5.5.6.1.2 | MarshalByteSecret | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/x448.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/x448.go | MIT |
func (c *x448) UnmarshalByteSecret(d []byte) []byte {
if len(d) != x448lib.Size+1 {
return nil
}
// Store without prefix
return d[1:]
} | UnmarshalByteSecret decodes a scalar from prefixed format to native.
See https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-crypto-refresh-06#section-5.5.5.6.1.2 | UnmarshalByteSecret | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/x448.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/x448.go | MIT |
func (c *ed448) MarshalBytePoint(x []byte) []byte {
// Return prefixed
return append([]byte{0x40}, x...)
} | MarshalBytePoint encodes the public point from native format, adding the prefix.
See https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-crypto-refresh-06#section-5.5.5.5 | MarshalBytePoint | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/ed448.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/ed448.go | MIT |
func (c *ed448) UnmarshalBytePoint(point []byte) (x []byte) {
if len(point) != ed448lib.PublicKeySize+1 {
return nil
}
// Strip prefix
return point[1:]
} | UnmarshalBytePoint decodes a point from prefixed format to native.
See https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-crypto-refresh-06#section-5.5.5.5 | UnmarshalBytePoint | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/ed448.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/ed448.go | MIT |
func (c *ed448) MarshalByteSecret(d []byte) []byte {
// Return prefixed
return append([]byte{0x40}, d...)
} | MarshalByteSecret encoded a scalar from native format to prefixed.
See https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-crypto-refresh-06#section-5.5.5.5 | MarshalByteSecret | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/ed448.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/ed448.go | MIT |
func (c *ed448) UnmarshalByteSecret(s []byte) (d []byte) {
// Check prefixed size
if len(s) != ed448lib.SeedSize+1 {
return nil
}
// Strip prefix
return s[1:]
} | UnmarshalByteSecret decodes a scalar from prefixed format to native.
See https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-crypto-refresh-06#section-5.5.5.5 | UnmarshalByteSecret | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/ed448.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/ed448.go | MIT |
func (c *ed448) MarshalSignature(sig []byte) (r, s []byte) {
return append([]byte{0x40}, sig...), []byte{}
} | MarshalSignature splits a signature in R and S, where R is in prefixed native format and
S is an MPI with value zero.
See https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-crypto-refresh-06#section-5.2.3.3.2 | MarshalSignature | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/ed448.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/ed448.go | MIT |
func (c *ed448) UnmarshalSignature(r, s []byte) (sig []byte) {
if len(r) != ed448lib.SignatureSize+1 {
return nil
}
return r[1:]
} | UnmarshalSignature decodes R and S in the native format. Only R is used, in prefixed native format.
See https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-crypto-refresh-06#section-5.2.3.3.2 | UnmarshalSignature | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/ed448.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/ed448.go | MIT |
func (mode AEADMode) TagLength() int {
switch mode {
case AEADModeEAX:
return 16
case AEADModeOCB:
return 16
case AEADModeGCM:
return 16
default:
return 0
}
} | TagLength returns the length in bytes of authentication tags. | TagLength | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/aead.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/aead.go | MIT |
func (mode AEADMode) NonceLength() int {
switch mode {
case AEADModeEAX:
return 16
case AEADModeOCB:
return 15
case AEADModeGCM:
return 12
default:
return 0
}
} | NonceLength returns the length in bytes of nonces. | NonceLength | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/aead.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/aead.go | MIT |
func (mode AEADMode) New(block cipher.Block) (alg cipher.AEAD) {
var err error
switch mode {
case AEADModeEAX:
alg, err = eax.NewEAX(block)
case AEADModeOCB:
alg, err = ocb.NewOCB(block)
case AEADModeGCM:
alg, err = cipher.NewGCM(block)
}
if err != nil {
panic(err.Error())
}
return alg
} | New returns a fresh instance of the given mode | New | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/aead.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/aead.go | MIT |
func (sk CipherFunction) Id() uint8 {
return uint8(sk)
} | ID returns the algorithm Id, as a byte, of cipher. | Id | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/cipher.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/cipher.go | MIT |
func (cipher CipherFunction) KeySize() int {
switch cipher {
case CAST5:
return cast5.KeySize
case AES128:
return 16
case AES192, TripleDES:
return 24
case AES256:
return 32
}
return 0
} | KeySize returns the key size, in bytes, of cipher. | KeySize | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/cipher.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/cipher.go | MIT |
func (cipher CipherFunction) BlockSize() int {
switch cipher {
case TripleDES:
return des.BlockSize
case CAST5:
return 8
case AES128, AES192, AES256:
return 16
}
return 0
} | BlockSize returns the block size, in bytes, of cipher. | BlockSize | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/cipher.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/cipher.go | MIT |
func (cipher CipherFunction) New(key []byte) (block cipher.Block) {
var err error
switch cipher {
case TripleDES:
block, err = des.NewTripleDESCipher(key)
case CAST5:
block, err = cast5.NewCipher(key)
case AES128, AES192, AES256:
block, err = aes.NewCipher(key)
}
if err != nil {
panic(err.Error())
}
return
} | New returns a fresh instance of the given cipher. | New | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/cipher.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/cipher.go | MIT |
func (h cryptoHash) Id() uint8 {
return h.id
} | Id returns the algorithm ID, as a byte, of cryptoHash. | Id | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/hash.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/hash.go | MIT |
func HashIdToHash(id byte) (h crypto.Hash, ok bool) {
if hash, ok := HashById[id]; ok {
return hash.HashFunc(), true
}
return 0, false
} | HashIdToHash returns a crypto.Hash which corresponds to the given OpenPGP
hash id. | HashIdToHash | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/hash.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/hash.go | MIT |
func HashIdToHashWithSha1(id byte) (h crypto.Hash, ok bool) {
if hash, ok := HashById[id]; ok {
return hash.HashFunc(), true
}
if id == SHA1.Id() {
return SHA1.HashFunc(), true
}
return 0, false
} | HashIdToHashWithSha1 returns a crypto.Hash which corresponds to the given OpenPGP
hash id, allowing sha1. | HashIdToHashWithSha1 | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/hash.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/hash.go | MIT |
func HashIdToString(id byte) (name string, ok bool) {
if hash, ok := HashById[id]; ok {
return hash.String(), true
}
return "", false
} | HashIdToString returns the name of the hash function corresponding to the
given OpenPGP hash id. | HashIdToString | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/hash.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/hash.go | MIT |
func HashToHashId(h crypto.Hash) (id byte, ok bool) {
for id, hash := range HashById {
if hash.HashFunc() == h {
return id, true
}
}
return 0, false
} | HashToHashId returns an OpenPGP hash id which corresponds the given Hash. | HashToHashId | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/hash.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/hash.go | MIT |
func HashToHashIdWithSha1(h crypto.Hash) (id byte, ok bool) {
for id, hash := range HashById {
if hash.HashFunc() == h {
return id, true
}
}
if h == SHA1.HashFunc() {
return SHA1.Id(), true
}
return 0, false
} | HashToHashIdWithSha1 returns an OpenPGP hash id which corresponds the given Hash,
allowing instances of SHA1 | HashToHashIdWithSha1 | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/hash.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm/hash.go | MIT |
func NewOID(bytes []byte) *OID {
switch len(bytes) {
case reservedOIDLength1, reservedOIDLength2:
panic("encoding: NewOID argument length is reserved")
default:
if len(bytes) > maxOID {
panic("encoding: NewOID argument too large")
}
}
return &OID{
bytes: bytes,
}
} | NewOID returns a OID initialized with bytes. | NewOID | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/oid.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/oid.go | MIT |
func (o *OID) Bytes() []byte {
return o.bytes
} | Bytes returns the decoded data. | Bytes | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/oid.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/oid.go | MIT |
func (o *OID) BitLength() uint16 {
return uint16(len(o.bytes) * 8)
} | BitLength is the size in bits of the decoded data. | BitLength | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/oid.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/oid.go | MIT |
func (o *OID) EncodedBytes() []byte {
return append([]byte{byte(len(o.bytes))}, o.bytes...)
} | EncodedBytes returns the encoded data. | EncodedBytes | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/oid.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/oid.go | MIT |
func (o *OID) EncodedLength() uint16 {
return uint16(1 + len(o.bytes))
} | EncodedLength is the size in bytes of the encoded data. | EncodedLength | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/oid.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/oid.go | MIT |
func (o *OID) ReadFrom(r io.Reader) (int64, error) {
var buf [1]byte
n, err := io.ReadFull(r, buf[:])
if err != nil {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
return int64(n), err
}
switch buf[0] {
case reservedOIDLength1, reservedOIDLength2:
return int64(n), errors.UnsupportedError("reserved for future extensions")
}
o.bytes = make([]byte, buf[0])
nn, err := io.ReadFull(r, o.bytes)
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
return int64(n) + int64(nn), err
} | ReadFrom reads into b the next OID from r. | ReadFrom | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/oid.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/oid.go | MIT |
func NewMPI(bytes []byte) *MPI {
for len(bytes) != 0 && bytes[0] == 0 {
bytes = bytes[1:]
}
if len(bytes) == 0 {
bitLength := uint16(0)
return &MPI{bytes, bitLength}
}
bitLength := 8*uint16(len(bytes)-1) + uint16(bits.Len8(bytes[0]))
return &MPI{bytes, bitLength}
} | NewMPI returns a MPI initialized with bytes. | NewMPI | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/mpi.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/mpi.go | MIT |
func (m *MPI) Bytes() []byte {
return m.bytes
} | Bytes returns the decoded data. | Bytes | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/mpi.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/mpi.go | MIT |
func (m *MPI) BitLength() uint16 {
return m.bitLength
} | BitLength is the size in bits of the decoded data. | BitLength | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/mpi.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/mpi.go | MIT |
func (m *MPI) EncodedBytes() []byte {
return append([]byte{byte(m.bitLength >> 8), byte(m.bitLength)}, m.bytes...)
} | EncodedBytes returns the encoded data. | EncodedBytes | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/mpi.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/mpi.go | MIT |
func (m *MPI) EncodedLength() uint16 {
return uint16(2 + len(m.bytes))
} | EncodedLength is the size in bytes of the encoded data. | EncodedLength | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/mpi.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/mpi.go | MIT |
func (m *MPI) ReadFrom(r io.Reader) (int64, error) {
var buf [2]byte
n, err := io.ReadFull(r, buf[0:])
if err != nil {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
return int64(n), err
}
m.bitLength = uint16(buf[0])<<8 | uint16(buf[1])
m.bytes = make([]byte, (int(m.bitLength)+7)/8)
nn, err := io.ReadFull(r, m.bytes)
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
// remove leading zero bytes from malformed GnuPG encoded MPIs:
// https://bugs.gnupg.org/gnupg/issue1853
// for _, b := range m.bytes {
// if b != 0 {
// break
// }
// m.bytes = m.bytes[1:]
// m.bitLength -= 8
// }
return int64(n) + int64(nn), err
} | ReadFrom reads into m the next MPI from r. | ReadFrom | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/mpi.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/mpi.go | MIT |
func (m *MPI) SetBig(n *big.Int) *MPI {
m.bytes = n.Bytes()
m.bitLength = uint16(n.BitLen())
return m
} | SetBig initializes m with the bits from n. | SetBig | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/mpi.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/internal/encoding/mpi.go | MIT |
func NewPublicKey() *PublicKey {
return &PublicKey{}
} | NewPublicKey creates a new empty ed25519 public key. | NewPublicKey | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/ed25519/ed25519.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/ed25519/ed25519.go | MIT |
func NewPrivateKey(key PublicKey) *PrivateKey {
return &PrivateKey{
PublicKey: key,
}
} | NewPrivateKey creates a new empty private key referencing the public key. | NewPrivateKey | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/ed25519/ed25519.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/ed25519/ed25519.go | MIT |
func (pk *PrivateKey) Seed() []byte {
return pk.Key[:SeedSize]
} | Seed returns the ed25519 private key secret seed.
The private key representation by RFC 8032. | Seed | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/ed25519/ed25519.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/ed25519/ed25519.go | MIT |
func (pk *PrivateKey) MarshalByteSecret() []byte {
return pk.Seed()
} | MarshalByteSecret returns the underlying 32 byte seed of the private key. | MarshalByteSecret | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/ed25519/ed25519.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/ed25519/ed25519.go | MIT |
func (sk *PrivateKey) UnmarshalByteSecret(seed []byte) error {
sk.Key = ed25519lib.NewKeyFromSeed(seed)
return nil
} | UnmarshalByteSecret computes the private key from the secret seed
and stores it in the private key object. | UnmarshalByteSecret | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/ed25519/ed25519.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/ed25519/ed25519.go | MIT |
func GenerateKey(rand io.Reader) (*PrivateKey, error) {
publicKey, privateKey, err := ed25519lib.GenerateKey(rand)
if err != nil {
return nil, err
}
privateKeyOut := new(PrivateKey)
privateKeyOut.PublicKey.Point = publicKey[:]
privateKeyOut.Key = privateKey[:]
return privateKeyOut, nil
} | GenerateKey generates a fresh private key with the provided randomness source. | GenerateKey | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/ed25519/ed25519.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/ed25519/ed25519.go | MIT |
func Sign(priv *PrivateKey, message []byte) ([]byte, error) {
return ed25519lib.Sign(priv.Key, message), nil
} | Sign signs a message with the ed25519 algorithm.
priv MUST be a valid key! Check this with Validate() before use. | Sign | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/ed25519/ed25519.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/ed25519/ed25519.go | MIT |
func Verify(pub *PublicKey, message []byte, signature []byte) bool {
return ed25519lib.Verify(pub.Point, message, signature)
} | Verify verifies an ed25519 signature. | Verify | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/ed25519/ed25519.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/ed25519/ed25519.go | MIT |
func Validate(priv *PrivateKey) error {
expectedPrivateKey := ed25519lib.NewKeyFromSeed(priv.Seed())
if subtle.ConstantTimeCompare(priv.Key, expectedPrivateKey) == 0 {
return errors.KeyInvalidError("ed25519: invalid ed25519 secret")
}
if subtle.ConstantTimeCompare(priv.PublicKey.Point, expectedPrivateKey[SeedSize:]) == 0 {
return errors.KeyInvalidError("ed25519: invalid ed25519 public key")
}
return nil
} | Validate checks if the ed25519 private key is valid. | Validate | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/ed25519/ed25519.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/ed25519/ed25519.go | MIT |
func WriteSignature(writer io.Writer, signature []byte) error {
_, err := writer.Write(signature)
return err
} | WriteSignature encodes and writes an ed25519 signature to writer. | WriteSignature | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/ed25519/ed25519.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/ed25519/ed25519.go | MIT |
func ReadSignature(reader io.Reader) ([]byte, error) {
signature := make([]byte, SignatureSize)
if _, err := io.ReadFull(reader, signature); err != nil {
return nil, err
}
return signature, nil
} | ReadSignature decodes an ed25519 signature from a reader. | ReadSignature | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/ed25519/ed25519.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/ed25519/ed25519.go | MIT |
func (op *OpaquePacket) Serialize(w io.Writer) (err error) {
err = serializeHeader(w, packetType(op.Tag), len(op.Contents))
if err == nil {
_, err = w.Write(op.Contents)
}
return
} | Serialize marshals the packet to a writer in its original form, including
the packet header. | Serialize | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/opaque.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/opaque.go | MIT |
func (op *OpaquePacket) Parse() (p Packet, err error) {
hdr := bytes.NewBuffer(nil)
err = serializeHeader(hdr, packetType(op.Tag), len(op.Contents))
if err != nil {
op.Reason = err
return op, err
}
p, err = Read(io.MultiReader(hdr, bytes.NewBuffer(op.Contents)))
if err != nil {
op.Reason = err
p = op
}
return
} | Parse attempts to parse the opaque contents into a structure supported by
this package. If the packet is not known then the result will be another
OpaquePacket. | Parse | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/opaque.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/opaque.go | MIT |
func (or *OpaqueReader) Next() (op *OpaquePacket, err error) {
tag, _, contents, err := readHeader(or.r)
if err != nil {
return
}
op = &OpaquePacket{Tag: uint8(tag), Reason: err}
err = op.parse(contents)
if err != nil {
consumeAll(contents)
}
return
} | Read the next OpaquePacket. | Next | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/opaque.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/opaque.go | MIT |
func OpaqueSubpackets(contents []byte) (result []*OpaqueSubpacket, err error) {
var (
subHeaderLen int
subPacket *OpaqueSubpacket
)
for len(contents) > 0 {
subHeaderLen, subPacket, err = nextSubpacket(contents)
if err != nil {
break
}
result = append(result, subPacket)
contents = contents[subHeaderLen+len(subPacket.Contents):]
}
return
} | OpaqueSubpackets extracts opaque, unparsed OpenPGP subpackets from
their byte representation. | OpaqueSubpackets | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/opaque.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/opaque.go | MIT |
func (ae *AEADEncrypted) Decrypt(ciph CipherFunction, key []byte) (io.ReadCloser, error) {
return ae.decrypt(key)
} | Decrypt returns a io.ReadCloser from which decrypted bytes can be read, or
an error. | Decrypt | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/aead_encrypted.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/aead_encrypted.go | MIT |
func (ae *AEADEncrypted) decrypt(key []byte) (io.ReadCloser, error) {
blockCipher := ae.cipher.new(key)
aead := ae.mode.new(blockCipher)
// Carry the first tagLen bytes
tagLen := ae.mode.TagLength()
peekedBytes := make([]byte, tagLen)
n, err := io.ReadFull(ae.Contents, peekedBytes)
if n < tagLen || (err != nil && err != io.EOF) {
return nil, errors.AEADError("Not enough data to decrypt:" + err.Error())
}
chunkSize := decodeAEADChunkSize(ae.chunkSizeByte)
return &aeadDecrypter{
aeadCrypter: aeadCrypter{
aead: aead,
chunkSize: chunkSize,
initialNonce: ae.initialNonce,
associatedData: ae.associatedData(),
chunkIndex: make([]byte, 8),
packetTag: packetTypeAEADEncrypted,
},
reader: ae.Contents,
peekedBytes: peekedBytes}, nil
} | decrypt prepares an aeadCrypter and returns a ReadCloser from which
decrypted bytes can be read (see aeadDecrypter.Read()). | decrypt | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/aead_encrypted.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/aead_encrypted.go | MIT |
func (ae *AEADEncrypted) associatedData() []byte {
return []byte{
0xD4,
aeadEncryptedVersion,
byte(ae.cipher),
byte(ae.mode),
ae.chunkSizeByte}
} | associatedData for chunks: tag, version, cipher, mode, chunk size byte | associatedData | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/aead_encrypted.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/aead_encrypted.go | MIT |
func NewOCFBEncrypter(block cipher.Block, randData []byte, resync OCFBResyncOption) (cipher.Stream, []byte) {
blockSize := block.BlockSize()
if len(randData) != blockSize {
return nil, nil
}
x := &ocfbEncrypter{
b: block,
fre: make([]byte, blockSize),
outUsed: 0,
}
prefix := make([]byte, blockSize+2)
block.Encrypt(x.fre, x.fre)
for i := 0; i < blockSize; i++ {
prefix[i] = randData[i] ^ x.fre[i]
}
block.Encrypt(x.fre, prefix[:blockSize])
prefix[blockSize] = x.fre[0] ^ randData[blockSize-2]
prefix[blockSize+1] = x.fre[1] ^ randData[blockSize-1]
if resync {
block.Encrypt(x.fre, prefix[2:])
} else {
x.fre[0] = prefix[blockSize]
x.fre[1] = prefix[blockSize+1]
x.outUsed = 2
}
return x, prefix
} | NewOCFBEncrypter returns a cipher.Stream which encrypts data with OpenPGP's
cipher feedback mode using the given cipher.Block, and an initial amount of
ciphertext. randData must be random bytes and be the same length as the
cipher.Block's block size. Resync determines if the "resynchronization step"
from RFC 4880, 13.9 step 7 is performed. Different parts of OpenPGP vary on
this point. | NewOCFBEncrypter | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/ocfb.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/ocfb.go | MIT |
func NewOCFBDecrypter(block cipher.Block, prefix []byte, resync OCFBResyncOption) cipher.Stream {
blockSize := block.BlockSize()
if len(prefix) != blockSize+2 {
return nil
}
x := &ocfbDecrypter{
b: block,
fre: make([]byte, blockSize),
outUsed: 0,
}
prefixCopy := make([]byte, len(prefix))
copy(prefixCopy, prefix)
block.Encrypt(x.fre, x.fre)
for i := 0; i < blockSize; i++ {
prefixCopy[i] ^= x.fre[i]
}
block.Encrypt(x.fre, prefix[:blockSize])
prefixCopy[blockSize] ^= x.fre[0]
prefixCopy[blockSize+1] ^= x.fre[1]
if resync {
block.Encrypt(x.fre, prefix[2:])
} else {
x.fre[0] = prefix[blockSize]
x.fre[1] = prefix[blockSize+1]
x.outUsed = 2
}
copy(prefix, prefixCopy)
return x
} | NewOCFBDecrypter returns a cipher.Stream which decrypts data with OpenPGP's
cipher feedback mode using the given cipher.Block. Prefix must be the first
blockSize + 2 bytes of the ciphertext, where blockSize is the cipher.Block's
block size. On successful exit, blockSize+2 bytes of decrypted data are written into
prefix. Resync determines if the "resynchronization step" from RFC 4880,
13.9 step 7 is performed. Different parts of OpenPGP vary on this point. | NewOCFBDecrypter | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/ocfb.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/ocfb.go | MIT |
func (c *Config) KeyLifetime() uint32 {
if c == nil {
return 0
}
return c.KeyLifetimeSecs
} | KeyLifetime returns the validity period of the key. | KeyLifetime | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/config.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/config.go | MIT |
func (c *Config) SigLifetime() uint32 {
if c == nil {
return 0
}
return c.SigLifetimeSecs
} | SigLifetime returns the validity period of the signature. | SigLifetime | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/config.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/config.go | MIT |
func (c *Config) PasswordHashIterations() int {
if c == nil || c.S2KCount == 0 {
return 0
}
return c.S2KCount
} | Deprecated: The hash iterations should now be queried via the S2K() method. | PasswordHashIterations | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/config.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/config.go | MIT |
func (conf *AEADConfig) Mode() AEADMode {
// If no preference is specified, OCB is used (which is mandatory to implement).
if conf == nil || conf.DefaultMode == 0 {
return AEADModeOCB
}
mode := conf.DefaultMode
if mode != AEADModeEAX && mode != AEADModeOCB && mode != AEADModeGCM {
panic("AEAD mode unsupported")
}
return mode
} | Mode returns the AEAD mode of operation. | Mode | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/aead_config.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/aead_config.go | MIT |
func (conf *AEADConfig) ChunkSizeByte() byte {
if conf == nil || conf.ChunkSize == 0 {
return 12 // 1 << (12 + 6) == 262144 bytes
}
chunkSize := conf.ChunkSize
exponent := bits.Len64(chunkSize) - 1
switch {
case exponent < 6:
exponent = 6
case exponent > 16:
exponent = 16
}
return byte(exponent - 6)
} | ChunkSizeByte returns the byte indicating the chunk size. The effective
chunk size is computed with the formula uint64(1) << (chunkSizeByte + 6)
limit to 16 = 4 MiB
https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-07.html#section-5.13.2 | ChunkSizeByte | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/aead_config.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/aead_config.go | MIT |
func decodeAEADChunkSize(c byte) int {
size := uint64(1 << (c + 6))
if size != uint64(int(size)) {
return 1 << 30
}
return int(size)
} | decodeAEADChunkSize returns the effective chunk size. In 32-bit systems, the
maximum returned value is 1 << 30. | decodeAEADChunkSize | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/aead_config.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/aead_config.go | MIT |
func (up *UnsupportedPacket) parse(read io.Reader) error {
err := up.IncompletePacket.parse(read)
if castedErr, ok := err.(errors.UnsupportedError); ok {
up.Error = castedErr
return nil
}
return err
} | Implements the Packet interface | parse | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/packet_unsupported.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/packet_unsupported.go | MIT |
func (pk *PublicKey) UpgradeToV5() {
pk.Version = 5
pk.setFingerprintAndKeyId()
} | UpgradeToV5 updates the version of the key to v5, and updates all necessary
fields. | UpgradeToV5 | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func (pk *PublicKey) UpgradeToV6() {
pk.Version = 6
pk.setFingerprintAndKeyId()
} | UpgradeToV6 updates the version of the key to v6, and updates all necessary
fields. | UpgradeToV6 | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func NewRSAPublicKey(creationTime time.Time, pub *rsa.PublicKey) *PublicKey {
pk := &PublicKey{
Version: 4,
CreationTime: creationTime,
PubKeyAlgo: PubKeyAlgoRSA,
PublicKey: pub,
n: new(encoding.MPI).SetBig(pub.N),
e: new(encoding.MPI).SetBig(big.NewInt(int64(pub.E))),
}
pk.setFingerprintAndKeyId()
return pk
} | NewRSAPublicKey returns a PublicKey that wraps the given rsa.PublicKey. | NewRSAPublicKey | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func NewDSAPublicKey(creationTime time.Time, pub *dsa.PublicKey) *PublicKey {
pk := &PublicKey{
Version: 4,
CreationTime: creationTime,
PubKeyAlgo: PubKeyAlgoDSA,
PublicKey: pub,
p: new(encoding.MPI).SetBig(pub.P),
q: new(encoding.MPI).SetBig(pub.Q),
g: new(encoding.MPI).SetBig(pub.G),
y: new(encoding.MPI).SetBig(pub.Y),
}
pk.setFingerprintAndKeyId()
return pk
} | NewDSAPublicKey returns a PublicKey that wraps the given dsa.PublicKey. | NewDSAPublicKey | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func NewElGamalPublicKey(creationTime time.Time, pub *elgamal.PublicKey) *PublicKey {
pk := &PublicKey{
Version: 4,
CreationTime: creationTime,
PubKeyAlgo: PubKeyAlgoElGamal,
PublicKey: pub,
p: new(encoding.MPI).SetBig(pub.P),
g: new(encoding.MPI).SetBig(pub.G),
y: new(encoding.MPI).SetBig(pub.Y),
}
pk.setFingerprintAndKeyId()
return pk
} | NewElGamalPublicKey returns a PublicKey that wraps the given elgamal.PublicKey. | NewElGamalPublicKey | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func (pk *PublicKey) parseRSA(r io.Reader) (err error) {
pk.n = new(encoding.MPI)
if _, err = pk.n.ReadFrom(r); err != nil {
return
}
pk.e = new(encoding.MPI)
if _, err = pk.e.ReadFrom(r); err != nil {
return
}
if len(pk.e.Bytes()) > 3 {
err = errors.UnsupportedError("large public exponent")
return
}
rsa := &rsa.PublicKey{
N: new(big.Int).SetBytes(pk.n.Bytes()),
E: 0,
}
for i := 0; i < len(pk.e.Bytes()); i++ {
rsa.E <<= 8
rsa.E |= int(pk.e.Bytes()[i])
}
pk.PublicKey = rsa
return
} | parseRSA parses RSA public key material from the given Reader. See RFC 4880,
section 5.5.2. | parseRSA | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func (pk *PublicKey) parseDSA(r io.Reader) (err error) {
pk.p = new(encoding.MPI)
if _, err = pk.p.ReadFrom(r); err != nil {
return
}
pk.q = new(encoding.MPI)
if _, err = pk.q.ReadFrom(r); err != nil {
return
}
pk.g = new(encoding.MPI)
if _, err = pk.g.ReadFrom(r); err != nil {
return
}
pk.y = new(encoding.MPI)
if _, err = pk.y.ReadFrom(r); err != nil {
return
}
dsa := new(dsa.PublicKey)
dsa.P = new(big.Int).SetBytes(pk.p.Bytes())
dsa.Q = new(big.Int).SetBytes(pk.q.Bytes())
dsa.G = new(big.Int).SetBytes(pk.g.Bytes())
dsa.Y = new(big.Int).SetBytes(pk.y.Bytes())
pk.PublicKey = dsa
return
} | parseDSA parses DSA public key material from the given Reader. See RFC 4880,
section 5.5.2. | parseDSA | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func (pk *PublicKey) parseElGamal(r io.Reader) (err error) {
pk.p = new(encoding.MPI)
if _, err = pk.p.ReadFrom(r); err != nil {
return
}
pk.g = new(encoding.MPI)
if _, err = pk.g.ReadFrom(r); err != nil {
return
}
pk.y = new(encoding.MPI)
if _, err = pk.y.ReadFrom(r); err != nil {
return
}
elgamal := new(elgamal.PublicKey)
elgamal.P = new(big.Int).SetBytes(pk.p.Bytes())
elgamal.G = new(big.Int).SetBytes(pk.g.Bytes())
elgamal.Y = new(big.Int).SetBytes(pk.y.Bytes())
pk.PublicKey = elgamal
return
} | parseElGamal parses ElGamal public key material from the given Reader. See
RFC 4880, section 5.5.2. | parseElGamal | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func (pk *PublicKey) parseECDSA(r io.Reader) (err error) {
pk.oid = new(encoding.OID)
if _, err = pk.oid.ReadFrom(r); err != nil {
return
}
curveInfo := ecc.FindByOid(pk.oid)
if curveInfo == nil {
return errors.UnsupportedError(fmt.Sprintf("unknown oid: %x", pk.oid))
}
pk.p = new(encoding.MPI)
if _, err = pk.p.ReadFrom(r); err != nil {
return
}
c, ok := curveInfo.Curve.(ecc.ECDSACurve)
if !ok {
return errors.UnsupportedError(fmt.Sprintf("unsupported oid: %x", pk.oid))
}
ecdsaKey := ecdsa.NewPublicKey(c)
err = ecdsaKey.UnmarshalPoint(pk.p.Bytes())
pk.PublicKey = ecdsaKey
return
} | parseECDSA parses ECDSA public key material from the given Reader. See
RFC 6637, Section 9. | parseECDSA | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func (pk *PublicKey) parseECDH(r io.Reader) (err error) {
pk.oid = new(encoding.OID)
if _, err = pk.oid.ReadFrom(r); err != nil {
return
}
curveInfo := ecc.FindByOid(pk.oid)
if curveInfo == nil {
return errors.UnsupportedError(fmt.Sprintf("unknown oid: %x", pk.oid))
}
pk.p = new(encoding.MPI)
if _, err = pk.p.ReadFrom(r); err != nil {
return
}
pk.kdf = new(encoding.OID)
if _, err = pk.kdf.ReadFrom(r); err != nil {
return
}
c, ok := curveInfo.Curve.(ecc.ECDHCurve)
if !ok {
return errors.UnsupportedError(fmt.Sprintf("unsupported oid: %x", pk.oid))
}
if kdfLen := len(pk.kdf.Bytes()); kdfLen < 3 {
return errors.UnsupportedError("unsupported ECDH KDF length: " + strconv.Itoa(kdfLen))
}
if reserved := pk.kdf.Bytes()[0]; reserved != 0x01 {
return errors.UnsupportedError("unsupported KDF reserved field: " + strconv.Itoa(int(reserved)))
}
kdfHash, ok := algorithm.HashById[pk.kdf.Bytes()[1]]
if !ok {
return errors.UnsupportedError("unsupported ECDH KDF hash: " + strconv.Itoa(int(pk.kdf.Bytes()[1])))
}
kdfCipher, ok := algorithm.CipherById[pk.kdf.Bytes()[2]]
if !ok {
return errors.UnsupportedError("unsupported ECDH KDF cipher: " + strconv.Itoa(int(pk.kdf.Bytes()[2])))
}
ecdhKey := ecdh.NewPublicKey(c, kdfHash, kdfCipher)
err = ecdhKey.UnmarshalPoint(pk.p.Bytes())
pk.PublicKey = ecdhKey
return
} | parseECDH parses ECDH public key material from the given Reader. See
RFC 6637, Section 9. | parseECDH | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func (pk *PublicKey) SerializeForHash(w io.Writer) error {
if err := pk.SerializeSignaturePrefix(w); err != nil {
return err
}
return pk.serializeWithoutHeaders(w)
} | SerializeForHash serializes the PublicKey to w with the special packet
header format needed for hashing. | SerializeForHash | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func (pk *PublicKey) SerializeSignaturePrefix(w io.Writer) error {
var pLength = pk.algorithmSpecificByteCount()
// version, timestamp, algorithm
pLength += versionSize + timestampSize + algorithmSize
if pk.Version >= 5 {
// key octet count (4).
pLength += 4
_, err := w.Write([]byte{
// When a v4 signature is made over a key, the hash data starts with the octet 0x99, followed by a two-octet length
// of the key, and then the body of the key packet. When a v6 signature is made over a key, the hash data starts
// with the salt, then octet 0x9B, followed by a four-octet length of the key, and then the body of the key packet.
0x95 + byte(pk.Version),
byte(pLength >> 24),
byte(pLength >> 16),
byte(pLength >> 8),
byte(pLength),
})
if err != nil {
return err
}
return nil
}
if _, err := w.Write([]byte{0x99, byte(pLength >> 8), byte(pLength)}); err != nil {
return err
}
return nil
} | SerializeSignaturePrefix writes the prefix for this public key to the given Writer.
The prefix is used when calculating a signature over this public key. See
RFC 4880, section 5.2.4. | SerializeSignaturePrefix | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func (pk *PublicKey) serializeWithoutHeaders(w io.Writer) (err error) {
t := uint32(pk.CreationTime.Unix())
if _, err = w.Write([]byte{
byte(pk.Version),
byte(t >> 24), byte(t >> 16), byte(t >> 8), byte(t),
byte(pk.PubKeyAlgo),
}); err != nil {
return
}
if pk.Version >= 5 {
n := pk.algorithmSpecificByteCount()
if _, err = w.Write([]byte{
byte(n >> 24), byte(n >> 16), byte(n >> 8), byte(n),
}); err != nil {
return
}
}
switch pk.PubKeyAlgo {
case PubKeyAlgoRSA, PubKeyAlgoRSAEncryptOnly, PubKeyAlgoRSASignOnly:
if _, err = w.Write(pk.n.EncodedBytes()); err != nil {
return
}
_, err = w.Write(pk.e.EncodedBytes())
return
case PubKeyAlgoDSA:
if _, err = w.Write(pk.p.EncodedBytes()); err != nil {
return
}
if _, err = w.Write(pk.q.EncodedBytes()); err != nil {
return
}
if _, err = w.Write(pk.g.EncodedBytes()); err != nil {
return
}
_, err = w.Write(pk.y.EncodedBytes())
return
case PubKeyAlgoElGamal:
if _, err = w.Write(pk.p.EncodedBytes()); err != nil {
return
}
if _, err = w.Write(pk.g.EncodedBytes()); err != nil {
return
}
_, err = w.Write(pk.y.EncodedBytes())
return
case PubKeyAlgoECDSA:
if _, err = w.Write(pk.oid.EncodedBytes()); err != nil {
return
}
_, err = w.Write(pk.p.EncodedBytes())
return
case PubKeyAlgoECDH:
if _, err = w.Write(pk.oid.EncodedBytes()); err != nil {
return
}
if _, err = w.Write(pk.p.EncodedBytes()); err != nil {
return
}
_, err = w.Write(pk.kdf.EncodedBytes())
return
case PubKeyAlgoEdDSA:
if _, err = w.Write(pk.oid.EncodedBytes()); err != nil {
return
}
_, err = w.Write(pk.p.EncodedBytes())
return
case PubKeyAlgoX25519:
publicKey := pk.PublicKey.(*x25519.PublicKey)
_, err = w.Write(publicKey.Point)
return
case PubKeyAlgoX448:
publicKey := pk.PublicKey.(*x448.PublicKey)
_, err = w.Write(publicKey.Point)
return
case PubKeyAlgoEd25519:
publicKey := pk.PublicKey.(*ed25519.PublicKey)
_, err = w.Write(publicKey.Point)
return
case PubKeyAlgoEd448:
publicKey := pk.PublicKey.(*ed448.PublicKey)
_, err = w.Write(publicKey.Point)
return
}
return errors.InvalidArgumentError("bad public-key algorithm")
} | serializeWithoutHeaders marshals the PublicKey to w in the form of an
OpenPGP public key packet, not including the packet header. | serializeWithoutHeaders | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func (pk *PublicKey) CanSign() bool {
return pk.PubKeyAlgo != PubKeyAlgoRSAEncryptOnly && pk.PubKeyAlgo != PubKeyAlgoElGamal && pk.PubKeyAlgo != PubKeyAlgoECDH
} | CanSign returns true iff this public key can generate signatures | CanSign | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func (pk *PublicKey) VerifySignature(signed hash.Hash, sig *Signature) (err error) {
if !pk.CanSign() {
return errors.InvalidArgumentError("public key cannot generate signatures")
}
if sig.Version == 5 && (sig.SigType == 0x00 || sig.SigType == 0x01) {
sig.AddMetadataToHashSuffix()
}
signed.Write(sig.HashSuffix)
hashBytes := signed.Sum(nil)
// see discussion https://github.com/ProtonMail/go-crypto/issues/107
if sig.Version >= 5 && (hashBytes[0] != sig.HashTag[0] || hashBytes[1] != sig.HashTag[1]) {
return errors.SignatureError("hash tag doesn't match")
}
if pk.PubKeyAlgo != sig.PubKeyAlgo {
return errors.InvalidArgumentError("public key and signature use different algorithms")
}
switch pk.PubKeyAlgo {
case PubKeyAlgoRSA, PubKeyAlgoRSASignOnly:
rsaPublicKey, _ := pk.PublicKey.(*rsa.PublicKey)
err = rsa.VerifyPKCS1v15(rsaPublicKey, sig.Hash, hashBytes, padToKeySize(rsaPublicKey, sig.RSASignature.Bytes()))
if err != nil {
return errors.SignatureError("RSA verification failure")
}
return nil
case PubKeyAlgoDSA:
dsaPublicKey, _ := pk.PublicKey.(*dsa.PublicKey)
// Need to truncate hashBytes to match FIPS 186-3 section 4.6.
subgroupSize := (dsaPublicKey.Q.BitLen() + 7) / 8
if len(hashBytes) > subgroupSize {
hashBytes = hashBytes[:subgroupSize]
}
if !dsa.Verify(dsaPublicKey, hashBytes, new(big.Int).SetBytes(sig.DSASigR.Bytes()), new(big.Int).SetBytes(sig.DSASigS.Bytes())) {
return errors.SignatureError("DSA verification failure")
}
return nil
case PubKeyAlgoECDSA:
ecdsaPublicKey := pk.PublicKey.(*ecdsa.PublicKey)
if !ecdsa.Verify(ecdsaPublicKey, hashBytes, new(big.Int).SetBytes(sig.ECDSASigR.Bytes()), new(big.Int).SetBytes(sig.ECDSASigS.Bytes())) {
return errors.SignatureError("ECDSA verification failure")
}
return nil
case PubKeyAlgoEdDSA:
eddsaPublicKey := pk.PublicKey.(*eddsa.PublicKey)
if !eddsa.Verify(eddsaPublicKey, hashBytes, sig.EdDSASigR.Bytes(), sig.EdDSASigS.Bytes()) {
return errors.SignatureError("EdDSA verification failure")
}
return nil
case PubKeyAlgoEd25519:
ed25519PublicKey := pk.PublicKey.(*ed25519.PublicKey)
if !ed25519.Verify(ed25519PublicKey, hashBytes, sig.EdSig) {
return errors.SignatureError("Ed25519 verification failure")
}
return nil
case PubKeyAlgoEd448:
ed448PublicKey := pk.PublicKey.(*ed448.PublicKey)
if !ed448.Verify(ed448PublicKey, hashBytes, sig.EdSig) {
return errors.SignatureError("ed448 verification failure")
}
return nil
default:
return errors.SignatureError("Unsupported public key algorithm used in signature")
}
} | VerifySignature returns nil iff sig is a valid signature, made by this
public key, of the data hashed into signed. signed is mutated by this call. | VerifySignature | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func keySignatureHash(pk, signed signingKey, hashFunc hash.Hash) (h hash.Hash, err error) {
h = hashFunc
// RFC 4880, section 5.2.4
err = pk.SerializeForHash(h)
if err != nil {
return nil, err
}
err = signed.SerializeForHash(h)
return
} | keySignatureHash returns a Hash of the message that needs to be signed for
pk to assert a subkey relationship to signed. | keySignatureHash | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func (pk *PublicKey) VerifyKeySignature(signed *PublicKey, sig *Signature) error {
preparedHash, err := sig.PrepareVerify()
if err != nil {
return err
}
h, err := keySignatureHash(pk, signed, preparedHash)
if err != nil {
return err
}
if err = pk.VerifySignature(h, sig); err != nil {
return err
}
if sig.FlagSign {
// Signing subkeys must be cross-signed. See
// https://www.gnupg.org/faq/subkey-cross-certify.html.
if sig.EmbeddedSignature == nil {
return errors.StructuralError("signing subkey is missing cross-signature")
}
preparedHashEmbedded, err := sig.EmbeddedSignature.PrepareVerify()
if err != nil {
return err
}
// Verify the cross-signature. This is calculated over the same
// data as the main signature, so we cannot just recursively
// call signed.VerifyKeySignature(...)
if h, err = keySignatureHash(pk, signed, preparedHashEmbedded); err != nil {
return errors.StructuralError("error while hashing for cross-signature: " + err.Error())
}
if err := signed.VerifySignature(h, sig.EmbeddedSignature); err != nil {
return errors.StructuralError("error while verifying cross-signature: " + err.Error())
}
}
return nil
} | VerifyKeySignature returns nil iff sig is a valid signature, made by this
public key, of signed. | VerifyKeySignature | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func (pk *PublicKey) VerifyRevocationSignature(sig *Signature) (err error) {
preparedHash, err := sig.PrepareVerify()
if err != nil {
return err
}
if keyRevocationHash(pk, preparedHash); err != nil {
return err
}
return pk.VerifySignature(preparedHash, sig)
} | VerifyRevocationSignature returns nil iff sig is a valid signature, made by this
public key. | VerifyRevocationSignature | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func (pk *PublicKey) VerifySubkeyRevocationSignature(sig *Signature, signed *PublicKey) (err error) {
preparedHash, err := sig.PrepareVerify()
if err != nil {
return err
}
h, err := keySignatureHash(pk, signed, preparedHash)
if err != nil {
return err
}
return pk.VerifySignature(h, sig)
} | VerifySubkeyRevocationSignature returns nil iff sig is a valid subkey revocation signature,
made by this public key, of signed. | VerifySubkeyRevocationSignature | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func userIdSignatureHash(id string, pk *PublicKey, h hash.Hash) (err error) {
// RFC 4880, section 5.2.4
if err := pk.SerializeSignaturePrefix(h); err != nil {
return err
}
if err := pk.serializeWithoutHeaders(h); err != nil {
return err
}
var buf [5]byte
buf[0] = 0xb4
buf[1] = byte(len(id) >> 24)
buf[2] = byte(len(id) >> 16)
buf[3] = byte(len(id) >> 8)
buf[4] = byte(len(id))
h.Write(buf[:])
h.Write([]byte(id))
return nil
} | userIdSignatureHash returns a Hash of the message that needs to be signed
to assert that pk is a valid key for id. | userIdSignatureHash | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func directKeySignatureHash(pk *PublicKey, h hash.Hash) (err error) {
return pk.SerializeForHash(h)
} | directKeySignatureHash returns a Hash of the message that needs to be signed. | directKeySignatureHash | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func (pk *PublicKey) VerifyUserIdSignature(id string, pub *PublicKey, sig *Signature) (err error) {
h, err := sig.PrepareVerify()
if err != nil {
return err
}
if err := userIdSignatureHash(id, pub, h); err != nil {
return err
}
return pk.VerifySignature(h, sig)
} | VerifyUserIdSignature returns nil iff sig is a valid signature, made by this
public key, that id is the identity of pub. | VerifyUserIdSignature | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func (pk *PublicKey) VerifyDirectKeySignature(sig *Signature) (err error) {
h, err := sig.PrepareVerify()
if err != nil {
return err
}
if err := directKeySignatureHash(pk, h); err != nil {
return err
}
return pk.VerifySignature(h, sig)
} | VerifyDirectKeySignature returns nil iff sig is a valid signature, made by this
public key. | VerifyDirectKeySignature | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func (pk *PublicKey) KeyIdString() string {
return fmt.Sprintf("%X", pk.Fingerprint[12:20])
} | KeyIdString returns the public key's fingerprint in capital hex
(e.g. "6C7EE1B8621CC013"). | KeyIdString | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func (pk *PublicKey) KeyIdShortString() string {
return fmt.Sprintf("%X", pk.Fingerprint[16:20])
} | KeyIdShortString returns the short form of public key's fingerprint
in capital hex, as shown by gpg --list-keys (e.g. "621CC013"). | KeyIdShortString | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func (pk *PublicKey) BitLength() (bitLength uint16, err error) {
switch pk.PubKeyAlgo {
case PubKeyAlgoRSA, PubKeyAlgoRSAEncryptOnly, PubKeyAlgoRSASignOnly:
bitLength = pk.n.BitLength()
case PubKeyAlgoDSA:
bitLength = pk.p.BitLength()
case PubKeyAlgoElGamal:
bitLength = pk.p.BitLength()
case PubKeyAlgoECDSA:
bitLength = pk.p.BitLength()
case PubKeyAlgoECDH:
bitLength = pk.p.BitLength()
case PubKeyAlgoEdDSA:
bitLength = pk.p.BitLength()
case PubKeyAlgoX25519:
bitLength = x25519.KeySize * 8
case PubKeyAlgoX448:
bitLength = x448.KeySize * 8
case PubKeyAlgoEd25519:
bitLength = ed25519.PublicKeySize * 8
case PubKeyAlgoEd448:
bitLength = ed448.PublicKeySize * 8
default:
err = errors.InvalidArgumentError("bad public-key algorithm")
}
return
} | BitLength returns the bit length for the given public key. | BitLength | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
func (pk *PublicKey) Curve() (curve Curve, err error) {
switch pk.PubKeyAlgo {
case PubKeyAlgoECDSA, PubKeyAlgoECDH, PubKeyAlgoEdDSA:
curveInfo := ecc.FindByOid(pk.oid)
if curveInfo == nil {
return "", errors.UnsupportedError(fmt.Sprintf("unknown oid: %x", pk.oid))
}
curve = Curve(curveInfo.GenName)
case PubKeyAlgoEd25519, PubKeyAlgoX25519:
curve = Curve25519
case PubKeyAlgoEd448, PubKeyAlgoX448:
curve = Curve448
default:
err = errors.InvalidArgumentError("public key does not operate with an elliptic curve")
}
return
} | Curve returns the used elliptic curve of this public key.
Returns an error if no elliptic curve is used. | Curve | go | integrations/terraform-provider-github | vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | https://github.com/integrations/terraform-provider-github/blob/master/vendor/github.com/ProtonMail/go-crypto/openpgp/packet/public_key.go | MIT |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.