-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows TPM Base Services (TBS) - Implement Tbsi_Get_OwnerAuth #276
base: master
Are you sure you want to change the base?
Changes from all commits
ab560ea
88411be
7134292
5a25af5
09908bb
782ab32
958971c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,3 +111,78 @@ func TestSubmitCommandLongResponse(t *testing.T) { | |
t.Fatalf("Got response of %v, expected %v", rawResponse, expectedGetRandomRawResponse) | ||
} | ||
} | ||
|
||
// Get Storage owner authorization delegation blob | ||
func TestGetStorageOwnerAuth(t *testing.T) { | ||
ctx := getContext(t) | ||
defer ctx.Close() | ||
|
||
authBufferLength, err := ctx.GetOwnerAuth(Storage20Authorization, nil) | ||
if err == ErrOwnerauthNotFound || err == ErrInternalError { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you sure that this check will only skip the test if the TBS call failed due to lack of admin rights? |
||
expectedErrorHint := "An internal error occurred. Are you running with Administrative permissions?" | ||
if err == ErrOwnerauthNotFound { | ||
expectedErrorHint = "Delegation blob not available in the registry." | ||
} | ||
t.Logf("Skipping retrieval of Storage authorization; %v", expectedErrorHint) | ||
t.SkipNow() | ||
} else if err != nil { | ||
t.Fatalf("Failed to get Storage authorization delegation blob size: %v", err) | ||
} | ||
|
||
storageOwnerAuth := make([]byte, authBufferLength) | ||
if _, err := ctx.GetOwnerAuth(Storage20Authorization, storageOwnerAuth); err != nil && err != ErrOwnerauthNotFound { | ||
t.Fatalf("Failed to retrieve Storage Authorization delegation blob from the registry: %v", err) | ||
} else if err == ErrOwnerauthNotFound { | ||
t.Log("Skipping retrieval of Storage authorization; Delegation blob not available in the registry.") | ||
t.SkipNow() | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might make sense to try using the auth value to make sure it came through correctly (i.e., doesn't need base64 decoded or something) |
||
|
||
// Get Endorsement owner authorization delegation blob | ||
func TestGetEndorsementOwnerAuth(t *testing.T) { | ||
ctx := getContext(t) | ||
defer ctx.Close() | ||
|
||
authBufferLength, err := ctx.GetOwnerAuth(Endorsement20Authorization, nil) | ||
if err == ErrOwnerauthNotFound || err == ErrInternalError { | ||
expectedErrorHint := "An internal error occurred. Are you running with Administrative permissions?" | ||
if err == ErrOwnerauthNotFound { | ||
expectedErrorHint = "Delegation blob not available in the registry." | ||
} | ||
t.Logf("Skipping retrieval of Endorsement authorization; %v", expectedErrorHint) | ||
t.SkipNow() | ||
} else if err != nil { | ||
t.Fatalf("Unexpected error occurred when retrieving Endorsement authorization delegation blob size: %v", err) | ||
} | ||
if authBufferLength <= 0 { | ||
t.Fatal("Expected positive Endorsement authorization delegation blob size") | ||
} | ||
|
||
endorsementOwnerAuth := make([]byte, authBufferLength) | ||
if _, err := ctx.GetOwnerAuth(Endorsement20Authorization, endorsementOwnerAuth); err != nil && err != ErrOwnerauthNotFound { | ||
t.Fatalf("Failed to retrieve Endorsement Authorization delegation blob from the registry: %v", err) | ||
} | ||
} | ||
|
||
// Get Full owner authorization delegation blob | ||
func TestGetFullOwnerAuth(t *testing.T) { | ||
ctx := getContext(t) | ||
defer ctx.Close() | ||
|
||
authBufferLength, err := ctx.GetOwnerAuth(FullAuthorization, nil) | ||
if err == ErrOwnerauthNotFound || err == ErrInternalError { | ||
expectedErrorHint := "An internal error occurred. Are you running with Administrative permissions?" | ||
if err == ErrOwnerauthNotFound { | ||
expectedErrorHint = "Delegation blob not available in the registry." | ||
} | ||
t.Logf("Skipping retrieval of Full authorization; %v", expectedErrorHint) | ||
t.SkipNow() | ||
} else if err != nil { | ||
t.Fatalf("Unexpected error occurred when retrieving Full authorization delegation blob size: %v", err) | ||
} | ||
|
||
fullOwnerAuth := make([]byte, authBufferLength) | ||
if _, err := ctx.GetOwnerAuth(FullAuthorization, fullOwnerAuth); err != nil && err != ErrOwnerauthNotFound { | ||
t.Fatalf("Failed to retrieve Full Authorization delegation blob from the registry: %v", err) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not allocate the slice from within this function and return ([]byte, error)?