Beispiel #1
0
func (p *Policy) SetPassword(pw string) error {
	var result C.TSS_RESULT
	if len(pw) == 0 {
		var zeros [20]byte
		result = C.Tspi_Policy_SetSecret(p.policy, C.TSS_SECRET_MODE_SHA1, 20, (*C.BYTE)(&zeros[0]))
	} else {
		panic("unimplemented")
	}

	if isError(result) {
		return Error{result}
	}
	return nil
}
Beispiel #2
0
func (p *Policy) SetKey(key [20]byte) error {
	if result := C.Tspi_Policy_SetSecret(p.policy, C.TSS_SECRET_MODE_SHA1, 20, (*C.BYTE)(&key[0])); isError(result) {
		return Error{result}
	}
	return nil
}
Beispiel #3
0
// SetSecret sets the secret for a policy. This policy may then be applied to
// another object.
func (policy *Policy) SetSecret(sectype int, secret []byte) error {
	err := tspiError(C.Tspi_Policy_SetSecret(policy.handle, (C.TSS_FLAG)(sectype), (C.UINT32)(len(secret)), (*C.BYTE)(&secret[0])))
	return err
}