...

Source file src/github.com/google/certificate-transparency-go/trillian/ctfe/structures.go

Documentation: github.com/google/certificate-transparency-go/trillian/ctfe

     1  // Copyright 2016 Google LLC. All Rights Reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package ctfe
    16  
    17  // Code to handle encoding / decoding various data structures used in RFC 6962. Does not
    18  // contain the low level serialization.
    19  
    20  import (
    21  	"crypto"
    22  	"crypto/sha256"
    23  
    24  	"github.com/google/certificate-transparency-go/x509"
    25  )
    26  
    27  const millisPerNano int64 = 1000 * 1000
    28  
    29  // GetCTLogID takes the key manager for a log and returns the LogID. (see RFC 6962 S3.2)
    30  // In CT V1 the log id is a hash of the public key.
    31  func GetCTLogID(pk crypto.PublicKey) ([sha256.Size]byte, error) {
    32  	pubBytes, err := x509.MarshalPKIXPublicKey(pk)
    33  	if err != nil {
    34  		return [sha256.Size]byte{}, err
    35  	}
    36  	return sha256.Sum256(pubBytes), nil
    37  }
    38  

View as plain text