Skip to content

Commit

Permalink
feat: Add KeyType API. (#105)
Browse files Browse the repository at this point in the history
* feat: Add KeyType API.
  • Loading branch information
clundin25 authored Oct 16, 2023
1 parent bd11497 commit 5192b8e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions cshared/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,29 @@ func SignForPython(configFilePath *C.char, digest *byte, digestLen int, sigHolde
return len(signature)
}

// GetKeyType returns a string representing ECP's key type.
// The key is derived from the ECP configuration.
//
//export GetKeyType
func GetKeyType(configFilePath *C.char) *C.char {
key, err := client.Cred(C.GoString(configFilePath))
if err != nil {
log.Printf("Could not create client using config %s: %v", C.GoString(configFilePath), err)
return C.CString("unknown")
}
defer func() {
if err = key.Close(); err != nil {
log.Printf("Failed to clean up key. %v", err)
}
}()
switch key.Public().(type) {
case *ecdsa.PublicKey:
return C.CString("EC")
case *rsa.PublicKey:
return C.CString("RSA")
default:
return C.CString("unknown")
}
}

func main() {}

0 comments on commit 5192b8e

Please sign in to comment.