Skip to content

Commit d56b55d

Browse files
committed
Add some debugging to PCP credential activation
1 parent 83d9767 commit d56b55d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

attest/pcp_windows.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"bytes"
2222
"crypto/x509"
2323
"encoding/binary"
24+
"encoding/hex"
2425
"fmt"
2526
"io"
2627
"syscall"
@@ -816,6 +817,9 @@ func (h *winPCP) ActivateCredential(hKey uintptr, activationBlob []byte) ([]byte
816817
return nil, err
817818
}
818819

820+
hexBlob := hex.EncodeToString(activationBlob)
821+
fmt.Println("activation blob", hexBlob)
822+
819823
r, _, msg := nCryptSetProperty.Call(hKey, uintptr(unsafe.Pointer(&utf16ActivationStr[0])), uintptr(unsafe.Pointer(&activationBlob[0])), uintptr(len(activationBlob)), 0)
820824
if r != 0 {
821825
if tpmErr := maybeWinErr(r); tpmErr != nil {
@@ -828,10 +832,14 @@ func (h *winPCP) ActivateCredential(hKey uintptr, activationBlob []byte) ([]byte
828832
var size uint32
829833
r, _, msg = nCryptGetProperty.Call(hKey, uintptr(unsafe.Pointer(&utf16ActivationStr[0])), uintptr(unsafe.Pointer(&secretBuff[0])), uintptr(len(secretBuff)), uintptr(unsafe.Pointer(&size)), 0)
830834
if r != 0 {
835+
fmt.Println("secret size", size)
836+
hexSecret := hex.EncodeToString(secretBuff)
837+
fmt.Println("secret blob", hexSecret)
838+
831839
if tpmErr := maybeWinErr(r); tpmErr != nil {
832840
msg = tpmErr
833841
}
834-
return nil, fmt.Errorf("NCryptGetProperty returned %X (%v) for key activation", r, msg)
842+
return nil, fmt.Errorf("NCryptGetProperty returned %X (%v) for key activation; activation blob: %s; secret size: %d; secret blob: %s", r, msg, hexBlob, size, hexSecret)
835843
}
836844
return secretBuff[:size], nil
837845
}

0 commit comments

Comments
 (0)