mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-04 01:09:36 +02:00
hpke: add hpke package (#3761)
* hpke: add hpke package * Update pkg/hpke/url.go Co-authored-by: bobby <1544881+desimone@users.noreply.github.com> * Update pkg/hpke/url.go Co-authored-by: bobby <1544881+desimone@users.noreply.github.com> * Update pkg/hpke/url.go Co-authored-by: bobby <1544881+desimone@users.noreply.github.com> * gofmt Co-authored-by: bobby <1544881+desimone@users.noreply.github.com>
This commit is contained in:
parent
c1a522cd82
commit
9e5eaa92c2
6 changed files with 324 additions and 0 deletions
32
pkg/hpke/hpke_test.go
Normal file
32
pkg/hpke/hpke_test.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
package hpke
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestSeal(t *testing.T) {
|
||||
k1, err := GeneratePrivateKey()
|
||||
require.NoError(t, err)
|
||||
k2, err := GeneratePrivateKey()
|
||||
require.NoError(t, err)
|
||||
|
||||
sealed, err := Seal(k1, k2.PublicKey(), []byte("HELLO WORLD"))
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, sealed)
|
||||
|
||||
message, err := Open(k2, k1.PublicKey(), sealed)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, []byte("HELLO WORLD"), message)
|
||||
}
|
||||
|
||||
func TestDerivePrivateKey(t *testing.T) {
|
||||
k1a := DerivePrivateKey([]byte("KEY 1"))
|
||||
k1b := DerivePrivateKey([]byte("KEY 1"))
|
||||
k2 := DerivePrivateKey([]byte("KEY 2"))
|
||||
|
||||
assert.Equal(t, k1a.String(), k1b.String())
|
||||
assert.NotEqual(t, k1a.String(), k2.String())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue