blob: 30ed8d833d9da27628b062b807ae7a6f5ed632cc [file] [log] [blame]
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build !cgo noopenssl !linux,!openssl android !amd64,!openssl
// See comments in ecdsa_openssl.go for an explanation of the choice of
// build tags.
package security
import (
"crypto/ecdsa"
"crypto/x509"
"fmt"
"v.io/v23/verror"
)
func newInMemoryECDSASignerImpl(key *ecdsa.PrivateKey) (Signer, error) {
return newGoStdlibSigner(key)
}
func newECDSAPublicKeyImpl(key *ecdsa.PublicKey) PublicKey {
return newGoStdlibPublicKey(key)
}
func unmarshalPublicKeyImpl(bytes []byte) (PublicKey, error) {
key, err := x509.ParsePKIXPublicKey(bytes)
if err != nil {
return nil, err
}
switch v := key.(type) {
case *ecdsa.PublicKey:
return newGoStdlibPublicKey(v), nil
default:
return nil, verror.New(errUnrecognizedKey, nil, fmt.Sprintf("%T", key))
}
}