ecdsa

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. //////////////////////////////////////////////////////////////////////////////

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. //////////////////////////////////////////////////////////////////////////////

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. //////////////////////////////////////////////////////////////////////////////

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. //////////////////////////////////////////////////////////////////////////////

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateParams

func ValidateParams(hashAlg string, curve string, encoding string) error

ValidateEcdsaParams validates ECDSA parameters. The hash's strength must not be weaker than the curve's strength. Only DER encoding is supported now.

Types

type EcdsaSign

type EcdsaSign struct {
	// contains filtered or unexported fields
}

ecdsaSign is an implementation of PublicKeySign for ECDSA. At the moment, the implementation only accepts DER encoding.

func NewEcdsaSign

func NewEcdsaSign(hashAlg string,
	curve string,
	encoding string,
	keyValue []byte) (*EcdsaSign, error)

NewEcdsaSign creates a new instance of EcdsaSign.

func NewEcdsaSignFromPrivateKey

func NewEcdsaSignFromPrivateKey(hashAlg string,
	encoding string,
	privateKey *ecdsa.PrivateKey) (*EcdsaSign, error)

NewEcdsaSignFromPrivateKey creates a new instance of EcdsaSign

func (*EcdsaSign) Sign

func (e *EcdsaSign) Sign(data []byte) ([]byte, error)

Sign computes a signature for the given data.

type EcdsaSignature

type EcdsaSignature struct {
	R, S *big.Int
}

ecdsaSignature is a struct holding r and s values of an ECDSA signature.

func DecodeSignature

func DecodeSignature(encodedBytes []byte,
	encoding string) (*EcdsaSignature, error)

DecodeSignature creates a new ECDSA signature using the given byte slice. The function assumes that the byte slice is the concatenation of the BigEndian representation of two big integer r and s.

func NewSignature

func NewSignature(r, s *big.Int) *EcdsaSignature

newSignature creates a new ecdsaSignature object.

func (*EcdsaSignature) Encode

func (sig *EcdsaSignature) Encode(encoding string) ([]byte, error)

Encode converts the signature to the given encoding format. Only DER encoding is supported now.

type EcdsaVerify

type EcdsaVerify struct {
	// contains filtered or unexported fields
}

ecdsaVerify is an implementation of PublicKeyVerify for ECDSA. At the moment, the implementation only accepts signatures with strict DER encoding.

func NewEcdsaVerify

func NewEcdsaVerify(hashAlg string,
	curve string,
	encoding string,
	x []byte,
	y []byte) (*EcdsaVerify, error)

NewEcdsaVerify creates a new instance of EcdsaVerify.

func NewEcdsaVerifyFromPublicKey

func NewEcdsaVerifyFromPublicKey(hashAlg string, encoding string,
	publicKey *ecdsa.PublicKey) (*EcdsaVerify, error)

NewEcdsaVerifyFromPublicKey creates a new instance of EcdsaVerify.

func (*EcdsaVerify) Verify

func (e *EcdsaVerify) Verify(signatureBytes []byte, data []byte) error

Verify verifies whether the given signature is valid for the given data. It returns an error if the signature is not valid; nil otherwise.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL