下面是 Java 中 Keytab 实现的源代码。此代码段从 keytab 文件中读取密钥版本。我无法理解这是如何工作的。为什么要执行按位与和左移操作?
我的代码叫什么:
KeyTab keytab = KeyTab.getInstance(keytabFile); // passing keytab file location.
此文件为二进制格式。KeyTabInputStream 读取数据。
private void load(KeyTabInputStream var1) throws IOException, RealmException {
this.entries.clear();
**this.kt_vno = var1.readVersion();**
if (this.kt_vno == 1281) {
var1.setNativeByteOrder();
}
boolean var2 = false;
while(var1.available() > 0) {
int var4 = var1.readEntryLength();
KeyTabEntry var3 = var1.readEntry(var4, this.kt_vno);
if (DEBUG) {
System.out.println(">>> KeyTab: load() entry length: " + var4 + "; type: " + (var3 != null ? var3.keyType : 0));
}
if (var3 != null) {
this.entries.addElement(var3);
}
}
}
public int readVersion() throws IOException {
int var1 = (this.read() & 255) << 8;
return var1 | this.read() & 255;
}