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KChka2UtPm5leHRzdWIgLSAweDIwKSA8IGluZm8tPnJna25zaXplKSAKLSAgICAgICYmIChka2UtPm5leHRzdWIgPiAweDIwKSkgewotICAgIAotICAgIF93OTVfd2Fsa3Jna24oc3Via2V5ID8gc3Via2V5IDogcHJldmtleSwgLyogWFhYIDwtLSBUaGlzIGlzIGEgaGFjayovCi0JCSAgaW5mby0+cmdrbmJ1ZmZlciArIGRrZS0+bmV4dHN1YiAtIDB4MjAsIAotCQkgIGluZm8pOwotICB9Ci0gIGlmIChzdWJrZXkpIFJlZ0Nsb3NlS2V5KCBzdWJrZXkgKTsKLQotICBpZiAoZGtlLT5uZXh0ICE9IC0xICYmIAotICAgICAgKChka2UtPm5leHQgLSAweDIwKSA8IGluZm8tPnJna25zaXplKSAmJiAKLSAgICAgIChka2UtPm5leHQgPiAweDIwKSkgewotICAgIF93OTVfd2Fsa3Jna24ocHJldmtleSwgIAotCQkgIGluZm8tPnJna25idWZmZXIgKyBka2UtPm5leHQgLSAweDIwLAotCQkgIGluZm8pOwotICB9CisJLyogbmV4dCBzdWIga2V5ICovCisJaWYgKGRrZS0+bmV4dHN1YiAhPSAweGZmZmZmZmZmKSAKKwl7CisgICAgCSAgX3c5NV9wYXJzZV9ka2UoaHN1YmtleSwgY3JlZywgcmdrbiwgKF93OTVka2UqKSgoY2hhciopcmdrbitka2UtPm5leHRzdWIpLCBsZXZlbC0xKTsKKwl9CisgIAorCXJldCA9IFRSVUU7CisJaWYgKGhzdWJrZXkgIT0gaGtleSkgUmVnQ2xvc2VLZXkoaHN1YmtleSk7CitlcnJvcjoJcmV0dXJuIHJldDsKIH0KLQorLyogZW5kIHdpbmRvd3MgOTUgbG9hZGVyICovCiAKIC8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKLSAqIF93OTVfbG9hZHJlZyBbSW50ZXJuYWxdCisgKglOYXRpdmVSZWdMb2FkS2V5IFtJb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isJICBjYXNlIFc5NV9SRUdfQ1JFR19JRDoKKwkgICAgeworCSAgICAgIF93OTVjcmVnICogY3JlZzsKKwkgICAgICBfdzk1cmdrbiAqIHJna247CisJICAgICAgY3JlZyA9IGJhc2U7CisJICAgICAgVFJBQ0VfKHJlZykoIkxvYWRpbmcgd2luOTUgcmVnaXN0cnkgJyVzJyAnJXMnXG4iLGZuLCBmdWxsX25hbWUubG9uZ19uYW1lKTsKKworCSAgICAgIC8qIGxvYWQgdGhlIGhlYWRlciAocmdrbikgKi8KKwkgICAgICByZ2tuID0gKF93OTVyZ2tuKikoY3JlZyArIDEpOworCSAgICAgIGlmIChyZ2tuLT5pZCAhPSBXOTVfUkVHX1JHS05fSUQpIAorCSAgICAgIHsKKwkJRVJSKCJzZWNvbmQgSUZGIGhlYWRlciBub3QgUkdLTiwgYnV0ICVseFxuIiwgcmdrbi0+aWQpOworCQlnb3RvIGVycm9yMTsKKwkgICAgICB9CisKKwkgICAgICByZXQgPSBfdzk1X3BhcnNlX2RrZShoa2V5LCBjcmVnLCByZ2tuLCBOVUxMLCBsZXZlbCk7CisJICAgIH0KKwkgICAgYnJlYWs7CisJICAvKiBudCAncmVnZicqLworCSAgY2FzZSBOVF9SRUdfSEVBREVSX0JMT0NLX0lEOgorCSAgICB7CisJICAgICAgbnRfcmVnZiAqIHJlZ2Y7CisJICAgICAgbnRfaGJpbiAqIGhiaW47CisJICAgICAgbnRfaGJpbl9zdWIgKiBoYmluX3N1YjsKKwkgICAgICBudF9uayogbms7CisKKwkgICAgICBUUkFDRV8ocmVnKSgiTG9hZGluZyBudCByZWdpc3RyeSAnJXMnICclcydcbiIsZm4sIGZ1bGxfbmFtZS5sb25nX25hbWUpOworCisJICAgICAgLyogc3RhcnQgYmxvY2sgKi8KKwkgICAgICByZWdmID0gYmFzZTsKKworCSAgICAgIC8qIGhiaW4gYmxvY2sgKi8KKwkgICAgICBoYmluID0gYmFzZSArIDB4MTAwMDsKKwkgICAgICBpZiAoaGJpbi0+aWQgIT0gTlRfUkVHX1BPT0xfQkxPQ0tfSUQpCisJICAgICAgeworCSAgICAgICAgRVJSXyhyZWcpKCAiJXMgaGJpbiBibG9jayBpbnZhbGlkXG4iLCBmbik7CisJICAgICAgICBnb3RvIGVycm9yMTsKKwkgICAgICB9CisKKwkgICAgICAvKiBoYmluX3N1YiBibG9jayAqLworCSAgICAgIGhiaW5fc3ViID0gKG50X2hiaW5fc3ViKikmKGhiaW4tPmhiaW5fc3ViKTsKKwkgICAgICBpZiAoKGhiaW5fc3ViLT5kYXRhWzBdICE9ICduJykgfHwgKGhiaW5fc3ViLT5kYXRhWzFdICE9ICdrJykpCisJICAgICAgeworCSAgICAgICAgRVJSXyhyZWcpKCAiJXMgaGJpbl9zdWIgYmxvY2sgaW52YWxpZFxuIiwgZm4pOworCSAgICAgICAgZ290byBlcnJvcjE7CisJICAgICAgfQorCisJICAgICAgLyogbmsgYmxvY2sgKi8KKwkgICAgICBuayA9IChudF9uayopJihoYmluX3N1Yi0+ZGF0YVswXSk7CisJICAgICAgaWYgKG5rLT5UeXBlICE9IE5UX1JFR19ST09UX0tFWV9CTE9DS19UWVBFKQorCSAgICAgIHsKKwkgICAgICAgIEVSUl8ocmVnKSggIiVzIHNwZWNpYWwgbmsgYmxvY2sgbm90IGZvdW5kXG4iLCBmbik7CisJICAgICAgICBnb3RvIGVycm9yMTsKKwkgICAgICB9CisKKwkgICAgICByZXQgPSBfbnRfcGFyc2VfbmsgKGhrZXksIGJhc2UrMHgxMDAwLCBuaywgbGV2ZWwpOworCSAgICB9CisJICAgIGJyZWFrOworCSAgZGVmYXVsdDoKKwkgICAgeworCSAgICAgIEVSUigidW5rbm93biBzaWduYXR1cmUgaW4gcmVnaXN0cnkgZmlsZSAlcy5cbiIsZm4pOworCSAgICAgIGdvdG8gZXJyb3IxOworCSAgICB9CiAJfQogCi0JLyogU1RFUCAxOiBLZXlsaW5rIHN0cnVjdHVyZXMgKi8KLQlpZiAoLTE9PV9sbHNlZWsoaGZ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