Documentation ¶
Overview ¶
Package jwa implements cryptographic algorithms defined in RFC 7518.
Index ¶
- Constants
- func RegisterEncryptionAlgorithm(alg EncryptionAlgorithm, f func() enc.Algorithm)
- func RegisterKeyManagementAlgorithm(alg KeyManagementAlgorithm, f func() keymanage.Algorithm)
- func RegisterSignatureAlgorithm(alg SignatureAlgorithm, f func() sig.Algorithm)
- type CompressionAlgorithm
- type EllipticCurve
- type EncryptionAlgorithm
- type KeyAlgorithm
- type KeyManagementAlgorithm
- type KeyType
- type SignatureAlgorithm
Constants ¶
const ( AlgorithmKey = "alg" EncryptionAlgorithmKey = "enc" CompressionAlgorithmKey = "zip" JWKSetURLKey = "jku" JSONWebKey = "jwk" KeyIDKey = "kid" X509URLKey = "x5u" X509CertificateChainKey = "x5c" X509CertificateSHA1Thumbprint = "x5t" X509CertificateSHA256Thumbprint = "x5t#S256" TypeKey = "typ" ContentTypeKey = "cty" CriticalKey = "crit" EphemeralPublicKeyKey = "epk" AgreementPartyUInfoKey = "apu" AgreementPartyVInfoKey = "apv" InitializationVectorKey = "iv" AuthenticationTagKey = "tag" PBES2SaltInputKey = "p2s" PBES2CountKey = "p2c" IssuerKey = "iss" SubjectKey = "sub" AudienceKey = "aud" Base64URLEncodePayloadKey = "b64" PASSporTExtensionIdentifierKey = "ppt" URLKey = "url" NonceKey = "nonce" )
JSON Web Signature and Encryption Header Parameters https://www.iana.org/assignments/jose/jose.xhtml
Variables ¶
This section is empty.
Functions ¶
func RegisterEncryptionAlgorithm ¶
func RegisterEncryptionAlgorithm(alg EncryptionAlgorithm, f func() enc.Algorithm)
func RegisterKeyManagementAlgorithm ¶
func RegisterKeyManagementAlgorithm(alg KeyManagementAlgorithm, f func() keymanage.Algorithm)
func RegisterSignatureAlgorithm ¶
func RegisterSignatureAlgorithm(alg SignatureAlgorithm, f func() sig.Algorithm)
Types ¶
type CompressionAlgorithm ¶
type CompressionAlgorithm string
const ( CompressionAlgorithmUnknown CompressionAlgorithm = "" // DEF is compression with the DEFLATE RFC 1951 algorithm. DEF CompressionAlgorithm = "DEF" )
func (CompressionAlgorithm) String ¶
func (zip CompressionAlgorithm) String() string
type EllipticCurve ¶
type EllipticCurve string
EllipticCurve is an EllipticCurve defined in the IANA "JSON Web Key Elliptic Curve".
const ( // P256 is a Curve which implements NIST P-256. P256 EllipticCurve = "P-256" // P384 is a Curve which implements NIST P-384. P384 EllipticCurve = "P-364" // P521 is a Curve which implements NIST P-521. P521 EllipticCurve = "P-521" // Ed25519 is Ed25519 signature algorithm key pairs. Ed25519 EllipticCurve = "Ed25519" // Ed448 is Ed448 signature algorithm key pairs. Ed448 EllipticCurve = "Ed448" // X25519 is X25519 function key pairs. X25519 EllipticCurve = "X25519" // X448 is X448 function key pairs. X448 EllipticCurve = "X448" // secp256k1 is SECG secp256k1 curve. Secp256k1 EllipticCurve = "secp256k1" )
func (EllipticCurve) String ¶
func (crv EllipticCurve) String() string
type EncryptionAlgorithm ¶
type EncryptionAlgorithm string
EncryptionAlgorithm an algorithm for content encryption defined in RFC 7518 Section.5. Cryptographic Algorithms for Content Encryption.
const ( // A128CBC_HS256 is AES_128_CBC_HMAC_SHA_256 authenticated encryption // algorithm, as defined in RFC 7518 Section 5.2.3. // import github.com/shogo82148/goat/jwa/acbc A128CBC_HS256 EncryptionAlgorithm = "A128CBC-HS256" // A192CBC_HS384 is AES_192_CBC_HMAC_SHA_384 authenticated encryption // algorithm, as defined in RFC 7518 Section 5.2.4. // import github.com/shogo82148/goat/jwa/acbc A192CBC_HS384 EncryptionAlgorithm = "A192CBC-HS384" // A256CBC_HS512 is AES_256_CBC_HMAC_SHA_512 authenticated encryption // algorithm, as defined in RFC 7518 Section 5.2.5. // import github.com/shogo82148/goat/jwa/acbc A256CBC_HS512 EncryptionAlgorithm = "A256CBC-HS512" // A128GCM is AES GCM using 128-bit key. // import github.com/shogo82148/goat/jwa/agcm A128GCM EncryptionAlgorithm = "A128GCM" // A192GCM is AES GCM using 192-bit key. // import github.com/shogo82148/goat/jwa/agcm A192GCM EncryptionAlgorithm = "A192GCM" // A256GCM is AES GCM using 256-bit key. // import github.com/shogo82148/goat/jwa/agcm A256GCM EncryptionAlgorithm = "A256GCM" )
func (EncryptionAlgorithm) Available ¶
func (enc EncryptionAlgorithm) Available() bool
func (EncryptionAlgorithm) CEKSize ¶
func (enc EncryptionAlgorithm) CEKSize() int
CEKSize returns the byte size of CEK(Content Encryption Key) for the algorithm.
func (EncryptionAlgorithm) IVSize ¶
func (enc EncryptionAlgorithm) IVSize() int
IVSice returns the byte size of IV(Initialization Vector) for the algorithm.
func (EncryptionAlgorithm) New ¶
func (enc EncryptionAlgorithm) New() enc.Algorithm
func (EncryptionAlgorithm) String ¶
func (enc EncryptionAlgorithm) String() string
type KeyAlgorithm ¶
type KeyAlgorithm string
KeyAlgorithm may be either SignatureAlgorithm or KeyManagementAlgorithm. It is a workaround for jwk.Key being able to contain different types of algorithms in its `alg` field.
type KeyManagementAlgorithm ¶
type KeyManagementAlgorithm string
KeyManagementAlgorithm is an algorithm for JSON Web Encryption (JWE) defined in the IANA JSON Web Signature and Encryption Algorithms.
const ( KeyManagementAlgorithmUnknown KeyManagementAlgorithm = "" // RSA1_5 is RSAES-PKCS1-v1_5. // import github.com/shogo82148/goat/jwa/rsapkcs1v15 RSA1_5 KeyManagementAlgorithm = "RSA1_5" // RSA_OAEP is RSAES OAEP. // import github.com/shogo82148/goat/jwa/rsapoaep RSA_OAEP KeyManagementAlgorithm = "RSA-OAEP" // RSA_OAEP_256 is RSAES OAEP using SHA-256 and MGF1 with SHA-256. // import github.com/shogo82148/goat/jwa/rsapoaep RSA_OAEP_256 KeyManagementAlgorithm = "RSA-OAEP-256" // A128KW is AES Key Wrap with default initial value using 128-bit key. // import github.com/shogo82148/goat/jwa/akw A128KW KeyManagementAlgorithm = "A128KW" // A192KW is AES Key Wrap with default initial value using 192-bit key. // import github.com/shogo82148/goat/jwa/akw A192KW KeyManagementAlgorithm = "A192KW" // A256KW is AES Key Wrap with default initial value using 256-bit key. // import github.com/shogo82148/goat/jwa/akw A256KW KeyManagementAlgorithm = "A256KW" // Direct is direct use of a shared symmetric key as the CEK. // import github.com/shogo82148/goat/jwa/dir Direct KeyManagementAlgorithm = "dir" // ECDH_ES is Elliptic Curve Diffie-Hellman Ephemeral Static key agreement using Concat KDF. // import github.com/shogo82148/goat/jwa/ecdhes ECDH_ES KeyManagementAlgorithm = "ECDH-ES" // ECDH_ES_A128KW is ECDH-ES using Concat KDF and CEK wrapped with "A128KW". // import github.com/shogo82148/goat/jwa/ecdhes ECDH_ES_A128KW KeyManagementAlgorithm = "ECDH-ES+A128KW" // ECDH_ES_A192KW is ECDH-ES using Concat KDF and CEK wrapped with "A192KW". // import github.com/shogo82148/goat/jwa/ecdhes ECDH_ES_A192KW KeyManagementAlgorithm = "ECDH-ES+A192KW" // ECDH_ES_A256KW is ECDH-ES using Concat KDF and CEK wrapped with "A256KW". // import github.com/shogo82148/goat/jwa/ecdhes ECDH_ES_A256KW KeyManagementAlgorithm = "ECDH-ES+A256KW" // A128GCMKW is Key wrapping with AES GCM using 128-bit key. // import github.com/shogo82148/goat/jwa/agcmkw A128GCMKW KeyManagementAlgorithm = "A128GCMKW" // A196GCMKW is Key wrapping with AES GCM using 196-bit key. // import github.com/shogo82148/goat/jwa/agcmkw A192GCMKW KeyManagementAlgorithm = "A192GCMKW" // A256GCMKW is Key wrapping with AES GCM using 256-bit key. // import github.com/shogo82148/goat/jwa/agcmkw A256GCMKW KeyManagementAlgorithm = "A256GCMKW" // PBES2_HS256_A128KW is PBES2 with HMAC SHA-256 and "A128KW" wrapping. // import github.com/shogo82148/goat/jwa/pbes2 PBES2_HS256_A128KW KeyManagementAlgorithm = "PBES2-HS256+A128KW" // PBES2_HS384_A192KW is PBES2 with HMAC SHA-384 and "A192KW" wrapping. // import github.com/shogo82148/goat/jwa/pbes2 PBES2_HS384_A192KW KeyManagementAlgorithm = "PBES2-HS384+A192KW" // PBES2_HS512_A256KW is PBES2 with HMAC SHA-512 and "A256KW" wrapping. // import github.com/shogo82148/goat/jwa/pbes2 PBES2_HS512_A256KW KeyManagementAlgorithm = "PBES2-HS512+A256KW" )
func (KeyManagementAlgorithm) Available ¶
func (alg KeyManagementAlgorithm) Available() bool
func (KeyManagementAlgorithm) KeyAlgorithm ¶
func (alg KeyManagementAlgorithm) KeyAlgorithm() KeyAlgorithm
func (KeyManagementAlgorithm) New ¶
func (alg KeyManagementAlgorithm) New() keymanage.Algorithm
func (KeyManagementAlgorithm) String ¶
func (alg KeyManagementAlgorithm) String() string
type SignatureAlgorithm ¶
type SignatureAlgorithm string
SignatureAlgorithm is an algorithm for JSON Web Signature (JWS) defined in the IANA "JSON Web Signature and Encryption Algorithms".
const ( SignatureAlgorithmUnknown SignatureAlgorithm = "" // HS256 is HMAC using SHA-256. // import github.com/shogo82148/goat/jwa/hs HS256 SignatureAlgorithm = "HS256" // HS384 is HMAC using SHA-384. // import github.com/shogo82148/goat/jwa/hs HS384 SignatureAlgorithm = "HS384" // HS512 is HMAC using SHA-512. // import github.com/shogo82148/goat/jwa/hs HS512 SignatureAlgorithm = "HS512" // RS256 is RSASSA-PKCS1-v1_5 using SHA-256. // import github.com/shogo82148/goat/jwa/rs RS256 SignatureAlgorithm = "RS256" // RS384 is RSASSA-PKCS1-v1_5 using SHA-384. // import github.com/shogo82148/goat/jwa/rs RS384 SignatureAlgorithm = "RS384" // RS512 is RSASSA-PKCS1-v1_5 using SHA-512. // import github.com/shogo82148/goat/jwa/rs RS512 SignatureAlgorithm = "RS512" // ES256 is ECDSA using P-256 and SHA-256. // import github.com/shogo82148/goat/jwa/es ES256 SignatureAlgorithm = "ES256" // ES384 is ECDSA using P-384 and SHA-384. // import github.com/shogo82148/goat/jwa/es ES384 SignatureAlgorithm = "ES384" // ES512 is ECDSA using P-521 and SHA-512. // import github.com/shogo82148/goat/jwa/es ES512 SignatureAlgorithm = "ES512" // PS256 is RSASSA-PSS using SHA-256 and MGF1 with SHA-256. // import github.com/shogo82148/goat/jwa/ps PS256 SignatureAlgorithm = "PS256" // PS384 is RSASSA-PSS using SHA-384 and MGF1 with SHA-384. // import github.com/shogo82148/goat/jwa/ps PS384 SignatureAlgorithm = "PS384" // PS512 is RSASSA-PSS using SHA-512 and MGF1 with SHA-512. // import github.com/shogo82148/goat/jwa/ps PS512 SignatureAlgorithm = "PS512" // None is no digital signature or MAC performed. // import github.com/shogo82148/goat/jwa/none None SignatureAlgorithm = "none" // EdDSA is Edwards-Curve Digital Signature Algorithm. // import github.com/shogo82148/goat/jwa/eddsa EdDSA SignatureAlgorithm = "EdDSA" // ES256K is ECDSA using secp256k1 curve and SHA-256. // import github.com/shogo82148/goat/jwa/es ES256K SignatureAlgorithm = "ES256K" )
func (SignatureAlgorithm) Available ¶
func (alg SignatureAlgorithm) Available() bool
func (SignatureAlgorithm) KeyAlgorithm ¶
func (alg SignatureAlgorithm) KeyAlgorithm() KeyAlgorithm
func (SignatureAlgorithm) New ¶
func (alg SignatureAlgorithm) New() sig.Algorithm
func (SignatureAlgorithm) String ¶
func (alg SignatureAlgorithm) String() string
Directories ¶
Path | Synopsis |
---|---|
Package acbc provides the AES_CBC_HMAC_SHA2 content encryption algorithm.
|
Package acbc provides the AES_CBC_HMAC_SHA2 content encryption algorithm. |
Package agcm provides the AES-GCM content encryption algorithm.
|
Package agcm provides the AES-GCM content encryption algorithm. |
package agcmkw provides the AES-GCM key encryption algorithm.
|
package agcmkw provides the AES-GCM key encryption algorithm. |
Package akw provides the AES key encryption algorithm.
|
Package akw provides the AES key encryption algorithm. |
Package dir provides the direct key wrapping algorithm.
|
Package dir provides the direct key wrapping algorithm. |
Package ecdhes provides the Elliptic Curve Diffie-Hellman Ephemeral Static (ECDH-ES) key agreement algorithm defined in RFC 6278.
|
Package ecdhes provides the Elliptic Curve Diffie-Hellman Ephemeral Static (ECDH-ES) key agreement algorithm defined in RFC 6278. |
Package eddsa provides the Elliptic Curve Diffie-Hellman key agreement algorithm defined in RFC 8032.
|
Package eddsa provides the Elliptic Curve Diffie-Hellman key agreement algorithm defined in RFC 8032. |
package es provides the ECDSA using SHA-2 signature algorithm.
|
package es provides the ECDSA using SHA-2 signature algorithm. |
Package hs provides the HMAC using SHA-2 signature algorithm.
|
Package hs provides the HMAC using SHA-2 signature algorithm. |
Package none provides none signature algorithm.
|
Package none provides none signature algorithm. |
Package pbes2 provides PBES2 with HMAC SHA-2 and AES Key wrapping algorithm.
|
Package pbes2 provides PBES2 with HMAC SHA-2 and AES Key wrapping algorithm. |
Package ps implements the RSASSA-PSS Digital signature algorithm.
|
Package ps implements the RSASSA-PSS Digital signature algorithm. |
Package rs provides the RSASSA-PKCS1-v1_5 using SHA-2 signature algorithm.
|
Package rs provides the RSASSA-PKCS1-v1_5 using SHA-2 signature algorithm. |
Package rsaoaep provides the RSA-OAEP key encryption algorithm.
|
Package rsaoaep provides the RSA-OAEP key encryption algorithm. |
Package rsaoaep provides the RSAES-PKCS1-v1_5 key encryption algorithm.
|
Package rsaoaep provides the RSAES-PKCS1-v1_5 key encryption algorithm. |