Sha256: 526fdcf4e6eb9c7934cbd9732dbd08aa4493eb1df2e6eadf6970354bc35a0d61

Contents?: true

Size: 1.33 KB

Versions: 16

Compression:

Stored size: 1.33 KB

Contents

package jose

func init() {
	RegisterJwa(&EcdhAesKW{ keySizeBits: 128, aesKW: &AesKW{ keySizeBits: 128}, ecdh: &Ecdh{directAgreement:false}})
	RegisterJwa(&EcdhAesKW{ keySizeBits: 192, aesKW: &AesKW{ keySizeBits: 192}, ecdh: &Ecdh{directAgreement:false}})
	RegisterJwa(&EcdhAesKW{ keySizeBits: 256, aesKW: &AesKW{ keySizeBits: 256}, ecdh: &Ecdh{directAgreement:false}})
}

// Elliptic curve Diffie–Hellman with AES Key Wrap key management algorithm implementation
type EcdhAesKW struct{
	keySizeBits int
	aesKW JwaAlgorithm
	ecdh JwaAlgorithm
}

func (alg *EcdhAesKW) Name() string {
	switch alg.keySizeBits {
		case 128: return ECDH_ES_A128KW
		case 192: return ECDH_ES_A192KW
		default: return  ECDH_ES_A256KW
	}
}

func (alg *EcdhAesKW) WrapNewKey(cekSizeBits int, key interface{}, header map[string]interface{}) (cek []byte, encryptedCek []byte, err error) {
	var kek []byte

	if kek,_,err=alg.ecdh.WrapNewKey(alg.keySizeBits, key, header);err!=nil {
		return nil,nil,err
	}
	
	return alg.aesKW.WrapNewKey(cekSizeBits,kek,header)	
}

func (alg *EcdhAesKW) Unwrap(encryptedCek []byte, key interface{}, cekSizeBits int, header map[string]interface{}) (cek []byte, err error) {
	var kek []byte
	
	if kek,err=alg.ecdh.Unwrap(nil, key, alg.keySizeBits, header);err!=nil {
		return nil,err
	}
	
	return alg.aesKW.Unwrap(encryptedCek,kek,cekSizeBits,header)
}

Version data entries

16 entries across 16 versions & 1 rubygems

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