Skip to content

Commit c52c4d1

Browse files
zaolinChriMarMe
authored andcommitted
Add missing key manifest functions
Signed-off-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com>
1 parent 955f8a5 commit c52c4d1

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package bgkey
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/linuxboot/fiano/pkg/intel/metadata/common/pretty"
7+
)
8+
9+
// Print prints the Key Manifest.
10+
func (m *Manifest) Print() {
11+
if m.KeyAndSignature.Signature.DataTotalSize() < 1 {
12+
fmt.Printf("%v\n", m.PrettyString(1, true, pretty.OptionOmitKeySignature(true)))
13+
fmt.Printf(" --KeyAndSignature--\n\tKey Manifest not signed!\n\n")
14+
} else {
15+
fmt.Printf("%v\n", m.PrettyString(1, true, pretty.OptionOmitKeySignature(false)))
16+
}
17+
}

pkg/intel/metadata/bg/crypto_routines.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,23 @@ func (a Algorithm) String() string {
8181
}
8282
return s.String()
8383
}
84+
85+
func GetAlgFromString(name string) (Algorithm, error) {
86+
n := strings.ToUpper(name)
87+
switch n {
88+
case "ALGUNKNOWN":
89+
return AlgUnknown, nil
90+
case "RSA":
91+
return AlgRSA, nil
92+
case "SHA1":
93+
return AlgSHA1, nil
94+
case "SHA256":
95+
return AlgSHA256, nil
96+
case "ALGNULL":
97+
return AlgNull, nil
98+
case "RSASSA":
99+
return AlgRSASSA, nil
100+
default:
101+
return AlgNull, fmt.Errorf("algorithm name provided unknown")
102+
}
103+
}

0 commit comments

Comments
 (0)