github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/crypto/internal/boring/ecdh.go (about) 1 // Copyright 2022 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build boringcrypto && linux && (amd64 || arm64) && !android && !msan 6 7 package boring 8 9 import "C" 10 11 type PublicKeyECDH struct { 12 curve string 13 key *C.GO_EC_POINT 14 group *C.GO_EC_GROUP 15 bytes []byte 16 } 17 18 type PrivateKeyECDH struct { 19 curve string 20 key *C.GO_EC_KEY 21 } 22 23 func NewPublicKeyECDH(curve string, bytes []byte) (*PublicKeyECDH, error) 24 25 func (k *PublicKeyECDH) Bytes() []byte 26 27 func NewPrivateKeyECDH(curve string, bytes []byte) (*PrivateKeyECDH, error) 28 29 func (k *PrivateKeyECDH) PublicKey() (*PublicKeyECDH, error) 30 31 func ECDH(priv *PrivateKeyECDH, pub *PublicKeyECDH) ([]byte, error) 32 33 func GenerateKeyECDH(curve string) (*PrivateKeyECDH, []byte, error)