Beispiel #1
0
func (validator *validatorImpl) sign(signKey interface{}, msg []byte) ([]byte, error) {
	sigma, err := utils.ECDSASign(signKey, msg)

	validator.peer.node.log.Debug("Signing message [%s], sigma [%s].", utils.EncodeBase64(msg), utils.EncodeBase64(sigma))

	return sigma, err
}
Beispiel #2
0
func TestSignatureVerifier(t *testing.T) {
	// Create a signature
	conf.InitSecurityLevel(256)

	cert, key, err := utils.NewSelfSignedCert()
	if err != nil {
		t.Fatal(err)
	}

	message := []byte("Hello World!")
	signature, err := utils.ECDSASign(key, message)
	if err != nil {
		t.Fatal(err)
	}

	// Instantiate a new SignatureVerifier
	sv := NewX509ECDSASignatureVerifier()

	// Verify the signature
	ok, err := sv.Verify(cert, signature, message)
	if err != nil {
		t.Fatal(err)
	}
	if !ok {
		t.Fatal("Signature does not verify")
	}
}
func (validator *validatorImpl) signWithEnrollmentKey(msg []byte) ([]byte, error) {
	sigma, err := utils.ECDSASign(validator.peer.node.enrollPrivKey, msg)

	validator.peer.node.log.Debug("Signing message [%s], sigma [%s].", utils.EncodeBase64(msg), utils.EncodeBase64(sigma))

	return sigma, err
}
Beispiel #4
0
func BenchmarkSign(b *testing.B) {
	b.StopTimer()
	b.ResetTimer()

	//b.Logf("#iterations %d\n", b.N)
	signKey, _ := utils.NewECDSAKey()
	hash := make([]byte, 48)

	for i := 0; i < b.N; i++ {
		rand.Read(hash)
		b.StartTimer()
		utils.ECDSASign(signKey, hash)
		b.StopTimer()
	}
}
Beispiel #5
0
func BenchmarkVerify(b *testing.B) {
	b.StopTimer()
	b.ResetTimer()

	//b.Logf("#iterations %d\n", b.N)
	signKey, _ := utils.NewECDSAKey()
	verKey := signKey.PublicKey
	hash := make([]byte, 48)

	for i := 0; i < b.N; i++ {
		rand.Read(hash)
		sigma, _ := utils.ECDSASign(signKey, hash)
		b.StartTimer()
		utils.ECDSAVerify(&verKey, hash, sigma)
		b.StopTimer()
	}
}
Beispiel #6
0
func (node *nodeImpl) signWithEnrollmentKey(msg []byte) ([]byte, error) {
	node.log.Debug("Signing message [%s].", utils.EncodeBase64(msg))
	return utils.ECDSASign(node.enrollPrivKey, msg)
}
Beispiel #7
0
func (node *nodeImpl) sign(signKey interface{}, msg []byte) ([]byte, error) {
	node.log.Debug("Signing message [%s].", utils.EncodeBase64(msg))
	return utils.ECDSASign(signKey, msg)
}
Beispiel #8
0
func (validator *validatorImpl) sign(signKey interface{}, msg []byte) ([]byte, error) {
	sigma, err := utils.ECDSASign(signKey, msg)

	return sigma, err
}
Beispiel #9
0
func (node *nodeImpl) signWithEnrollmentKey(msg []byte) ([]byte, error) {
	return utils.ECDSASign(node.enrollPrivKey, msg)
}
Beispiel #10
0
func (node *nodeImpl) sign(signKey interface{}, msg []byte) ([]byte, error) {
	return utils.ECDSASign(signKey, msg)
}