github.com/transparency-dev/armored-witness-boot@v0.1.0/storage/card.go (about)

     1  // Copyright 2022 The Armored Witness Boot authors. 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 storage provides utilities for reading armored-witness-boot
    16  // configuration and kernel files.
    17  package storage
    18  
    19  import (
    20  	"github.com/usbarmory/tamago/soc/nxp/usdhc"
    21  
    22  	"github.com/transparency-dev/armored-witness-boot/config"
    23  )
    24  
    25  // Configuration reads an armored-witness-boot configuration data gob from a
    26  // fixed offset on an MMC/SD card.
    27  func Configuration(card *usdhc.USDHC, offset int64, size int64) (c *config.Config, err error) {
    28  	buf, err := card.Read(offset, size)
    29  
    30  	if err != nil {
    31  		return
    32  	}
    33  
    34  	c = &config.Config{}
    35  	err = c.Decode(buf)
    36  
    37  	return
    38  }