aboutsummaryrefslogtreecommitdiff
path: root/types.go
blob: b05bd4057a8486c3a96d1ed164429810dcaf03c2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package pki

import (
  "crypto"
)

// this file holds all the interfaces used in the program until it can be split
// properly

const PemLabelPublic = "PUBLIC KEY"

type (
  // interface for any private key
  PrivateKey interface {
    // derive a public key from the private key
    Public() PublicKey
    // sign a message with the private key
    Sign(message []byte) ([]byte, error)

    // return the private key structure
    privateKey() crypto.PrivateKey
  }

  // interface for any public key
  PublicKey interface {
    Pemmer
    // use the public key to verify a message against a signature
    Verify(message []byte, signature []byte) (bool, error)
  }

  Pemmer interface {
    MarshalPem() (marshalledPemBlock, error)
  }
)