|
|
@@ -113,19 +113,19 @@ func newEntry() entry {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func (k Keytab) String() string {
|
|
|
+func (kt Keytab) String() string {
|
|
|
var s string
|
|
|
s = `KVNO Timestamp Principal ET Key
|
|
|
---- ----------------- -------------------------------------------------------- -- ----------------------------------------------------------------
|
|
|
`
|
|
|
- for _, entry := range k.Entries {
|
|
|
+ for _, entry := range kt.Entries {
|
|
|
s += entry.String() + "\n"
|
|
|
}
|
|
|
return s
|
|
|
}
|
|
|
|
|
|
// AddEntry adds an entry to the keytab. The password should be provided in plain text and it will be converted using the defined enctype to be stored.
|
|
|
-func (k *Keytab) AddEntry(principalName, realm, password string, ts time.Time, KVNO uint8, encType int32) error {
|
|
|
+func (kt *Keytab) AddEntry(principalName, realm, password string, ts time.Time, KVNO uint8, encType int32) error {
|
|
|
// Generate a key from the password
|
|
|
princ, _ := types.ParseSPNString(principalName)
|
|
|
key, _, err := crypto.GetKeyFromPassword(password, princ, realm, encType, types.PADataSequence{})
|
|
|
@@ -136,7 +136,7 @@ func (k *Keytab) AddEntry(principalName, realm, password string, ts time.Time, K
|
|
|
// Populate the keytab entry principal
|
|
|
ktep := newPrincipal()
|
|
|
ktep.NumComponents = int16(len(princ.NameString))
|
|
|
- if k.version == 1 {
|
|
|
+ if kt.version == 1 {
|
|
|
ktep.NumComponents += 1
|
|
|
}
|
|
|
|
|
|
@@ -152,7 +152,7 @@ func (k *Keytab) AddEntry(principalName, realm, password string, ts time.Time, K
|
|
|
e.KVNO = uint32(KVNO)
|
|
|
e.Key = key
|
|
|
|
|
|
- k.Entries = append(k.Entries, e)
|
|
|
+ kt.Entries = append(kt.Entries, e)
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
@@ -521,8 +521,8 @@ func isNativeEndianLittle() bool {
|
|
|
}
|
|
|
|
|
|
// JSON return information about the keys held in the keytab in a JSON format.
|
|
|
-func (k *Keytab) JSON() (string, error) {
|
|
|
- b, err := json.MarshalIndent(k, "", " ")
|
|
|
+func (kt *Keytab) JSON() (string, error) {
|
|
|
+ b, err := json.MarshalIndent(kt, "", " ")
|
|
|
if err != nil {
|
|
|
return "", err
|
|
|
}
|