(peerPublicKey []byte)
| 165 | } |
| 166 | |
| 167 | func (p *nistParameters) SharedKey(peerPublicKey []byte) []byte { |
| 168 | curve, _ := curveForCurveID(p.curveID) |
| 169 | // Unmarshal also checks whether the given point is on the curve. |
| 170 | x, y := elliptic.Unmarshal(curve, peerPublicKey) |
| 171 | if x == nil { |
| 172 | return nil |
| 173 | } |
| 174 | |
| 175 | xShared, _ := curve.ScalarMult(x, y, p.privateKey) |
| 176 | sharedKey := make([]byte, (curve.Params().BitSize+7)/8) |
| 177 | return xShared.FillBytes(sharedKey) |
| 178 | } |
| 179 | |
| 180 | type x25519Parameters struct { |
| 181 | privateKey []byte |
nothing calls this directly
no test coverage detected