aboutsummaryrefslogblamecommitdiff
path: root/types.go
blob: c2a45999c8e1a87b6fb62fec990e0fd69a590d26 (plain) (tree)
1
2
3
4
5
6
7
8
9
           







                                                                               

                                   




                                               



                                                                     

                                       
                                  



                                 
          
                                                                 
                                                                            





                                            
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 using the public key and the given hash method.
    // To use a hash method, include the package
    //   import _ "crypto/sha512"
    Sign(message []byte, hash crypto.Hash) ([]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, hash crypto.Hash) (bool, error)
  }

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