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mZvLmJnX2Rlc2NbaV0uYmdfZmxhZ3MgJiBFWFQ0X0JHX0JMT0NLX1VOSU5JVCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgID8gMAorICAgICAgICAgICAgICAgICAgICAgICAgICAgOiBiaXRtYXBfZ2V0X2JpdChibG9ja19iaXRtYXAsIGJsb2NrKTsKICAgICAgICAgICAgIHVwZGF0ZV9wcm9ncmVzcyhkYXRhLCB1c2VkKTsKICAgICAgICAgICAgIGlmICh1c2VkKSB7CiAgICAgICAgICAgICAgICAgaWYgKGRhdGEtPmNvdW50ID09IDApIHsKQEAgLTIzMiw4ICsyMjIsOCBAQAogICAgICAgICAgICAgb2Zmc2V0ICs9IGluZm8uYmxvY2tfc2l6ZTsKIAogICAgICAgICAgICAgLyogV3JpdGUgZGF0YSBpZiB3ZSBhcmUgYWxpZ25lZCBvciBidWZmZXIgc2l6ZSByZWFjaGVkICovCi0gICAgICAgICAgICBpZiAob2Zmc2V0ICUgKGluZm8uYmxvY2tfc2l6ZSAqIEJMT0NLU19BVF9BX1RJTUUpID09IDAKLSAgICAgICAgICAgICAgICB8fCBkYXRhLT5jb3VudCA9PSBCTE9DS1NfQVRfQV9USU1FKSB7CisgICAgICAgICAgICBpZiAob2Zmc2V0ICUgKGluZm8uYmxvY2tfc2l6ZSAqIEJMT0NLU19BVF9BX1RJTUUpID09IDAgfHwKKyAgICAgICAgICAgICAgICBkYXRhLT5jb3VudCA9PSBCTE9DS1NfQVRfQV9USU1FKSB7CiAgICAgICAgICAgICAgICAgaWYgKGZsdXNoX291dHN0YW5kaW5nX2RhdGEoZGF0YSkpIHsKICAgICAgICAgICAgICAgICAgICAgZ290byBlcnJvdXQ7CiAgICAgICAgICAgICAgICAgfQpAQCAtMjYwLDcgKzI1MCw3IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sIHNldF9wcm9ncmVzc19wcm9wZXJ0aWVzKSB7CiAgICAgdTMyIGk7CiAgICAgc3RydWN0I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HJpbmcoIi9zeXMvZnMvIikgKyBmc3RhYi0+cmVjc1tpXS5mc190eXBlICsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICIvIiArIEJhc2VuYW1lKGdjX3BhdGgpKTsKKyAgICAgICAgICAgICAgICBSZWFscGF0aCgKKyAgICAgICAgICAgICAgICAgICAgYW5kcm9pZDo6dm9sZDo6QmxvY2tEZXZpY2VGb3JQYXRoKHN0ZDo6c3RyaW5nKGZzdGFiLT5yZWNzW2ldLm1vdW50X3BvaW50KSArICIvIiksCisgICAgICAgICAgICAgICAgICAgICZnY19wYXRoKSkgeworICAgICAgICAgICAgICAgIHBhdGhzLT5wdXNoX2JhY2soc3RkOjpzdHJpbmcoIi9zeXMvZnMvIikgKyBmc3RhYi0+cmVjc1tpXS5mc190eXBlICsgIi8iICsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEJhc2VuYW1lKGdjX3BhdGgpKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQogCkBAIC0xODQsOCArMTgyLDggQEAKICAgICAgICAgICAgIH0KICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIG5zZWNzX3QgdGltZSA9IHN5c3RlbVRpbWUoU1lTVEVNX1RJTUVfQk9PVFRJTUUpIC0gc3RhcnQ7Ci0gICAgICAgICAgICBMT0coSU5GTykgPDwgIlRyaW1tZWQgIiA8PCByYW5nZS5sZW4gPDwgIiBieXRlcyBvbiAiIDw8IHBhdGgKLSAgICAgICAgICAgICAgICAgICAgPDwgIiBpbiAiIDw8IG5hbm9zZWNvbmRzX3RvX21pbGxpc2Vjb25kcyh0aW1lKSA8PCAibXMiOworICAgICAgICAgICAgTE9HKElORk8pIDw8ICJUcmltbWVkICIgPDwgcmFuZ2UubGVuIDw8ICIgYnl0ZXMgb24gIiA8PCBwYXRoIDw8ICIgaW4gIgorICAgICAgICAgICAgICAgICAgICAgIDw8IG5hbm9zZWNvbmRzX3RvX21pbGxpc2Vjb25kcyh0aW1lKSA8PCAibXMiOwogICAgICAgICAgICAgZXh0cmFzLnB1dExvbmcoU3RyaW5nMTYoImJ5dGVzIiksIHJhbmdlLmxlbik7CiAgICAgICAgICAgICBleHRyYXMucHV0TG9uZyhTdHJpbmcxNigidGltZSIpLCB0aW1lKTsKICAgICAgICAgICAgIGlmIChsaXN0ZW5lcikgewpAQCAtMjMwLDggKzIyOCw4IEBACiAgICAgICAgIH0KIAogICAgICAgICBsay5sb2NrKCk7Ci0gICAgICAgIGFib3J0ZWQgPSBjdl9hYm9ydC53YWl0X2ZvcihsaywgMTBzLCBbXXsKLSAgICAgICAgICAgIHJldHVybiBpZGxlX21haW50X3N0YXQgPT0gSWRsZU1haW50U3RhdHM6OmtBYm9ydDt9KTsKKyAgICAgICAgYWJvcnRlZCA9CisgICAgICAgICAgICBjdl9hYm9ydC53YWl0X2ZvcihsaywgMTBzLCBbXSB7IHJldHVybiBpZGxlX21haW50X3N0YXQgPT0gSWRsZU1haW50U3RhdHM6OmtBYm9ydDsgfSk7CiAgICAgICAgIGxrLnVubG9jaygpOwogICAgIH0KIApAQCAtMjY3LDcgKzI2NSw3IEBACiBzdGF0aWMgdm9pZCBydW5EZXZHY0ZzdGFiKHZvaWQpIHsKICAgICBzdGQ6OnVuaXF1ZV9wdHI8ZnN0YWIsIGRlY2x0eXBlKCZmc19tZ3JfZnJlZV9mc3RhYik+IGZzdGFiKGZzX21ncl9yZWFkX2ZzdGFiX2RlZmF1bHQoKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZzX21ncl9mcmVlX2ZzdGFiKTsKLSAgICBzdHJ1Y3QgZnN0YWJfcmVjICpyZWMgPSBOVUxMOworICAgIHN0cnVjdCBmc3RhYl9yZWMqIHJlYyA9IE5VTEw7CiAKICAgICBmb3IgKGludCBpID0gMDsgaSA8IGZzdGFiLT5udW1fZW50cmllczsgaSsrKSB7CiAgICAgICAgIGlmIChmc19tZ3JfaGF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dGF0dXNfdCBHZW5lcmF0ZVJhbmRvbVV1aWQoc3RkOjpzdHJpbmcmIG91dCkgewogICAgIHN0YXR1c190IHJlcyA9IFJlYWRSYW5kb21CeXRlcygxNiwgb3V0KTsKICAgICBpZiAocmVzID09IE9LKSB7Ci0gICAgICAgIG91dFs2XSAmPSAweDBmOyAgLyogY2xlYXIgdmVyc2lvbiAgICAgICAgKi8KLSAgICAgICAgb3V0WzZdIHw9IDB4NDA7ICAvKiBzZXQgdG8gdmVyc2lvbiA0ICAgICAqLwotICAgICAgICBvdXRbOF0gJj0gMHgzZjsgIC8qIGNsZWFyIHZhcmlhbnQgICAgICAgICovCi0gICAgICAgIG91dFs4XSB8PSAweDgwOyAgLyogc2V0IHRvIElFVEYgdmFyaWFudCAgKi8KKyAgICAgICAgb3V0WzZdICY9IDB4MGY7IC8qIGNsZWFyIHZlcnNpb24gICAgICAgICovCisgICAgICAgIG91dFs2XSB8PSAweDQwOyAvKiBzZXQgdG8gdmVyc2lvbiA0ICAgICAqLworICAgICAgICBvdXRbOF0gJj0gMHgzZjsgLyogY2xlYXIgdmFyaWFudCAgICAgICAgKi8KKyAgICAgICAgb3V0WzhdIHw9IDB4ODA7IC8qIHNldCB0byBJRVRGIHZhcmlhbnQgICovCiAgICAgfQogICAgIHJldHVybiByZXM7CiB9CkBAIC00MTUsMjQgKzQxNCwyNiBAQAogICAgIGZvciAoc2l6ZV90IGkgPSAwOyBpIDwgaGV4LnNpemUoKTsgaSsrKSB7CiAgICAgICAgIGludCB2YWwgPSAwOwogICAgICAgICBzd2l0Y2ggKGhleFtpXSkgewotICAgICAgICBjYXNlICcgJzogY2FzZSAnLSc6IGNhc2UgJzonOiBjb250aW51ZTsKLSAgICAgICAgY2FzZSAnZic6IGNhc2UgJ0YnOiB2YWwgPSAxNTsgYnJlYWs7Ci0gICAgICAgIGNhc2UgJ2UnOiBjYXNlICdFJzogdmFsID0gMTQ7IGJyZWFrOwotICAgICAgICBjYXNlICdkJzogY2FzZSAn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YXNlICdiJzogY2FzZSAnQic6IHZhbCA9IDExOyBicmVhazsKKyAgICAgICAgICAgIGNhc2UgJ2EnOiBjYXNlICdBJzogdmFsID0gMTA7IGJyZWFrOworICAgICAgICAgICAgY2FzZSAnOSc6IHZhbCA9IDk7IGJyZWFrOworICAgICAgICAgICAgY2FzZSAnOCc6IHZhbCA9IDg7IGJyZWFrOworICAgICAgICAgICAgY2FzZSAnNyc6IHZhbCA9IDc7IGJyZWFrOworICAgICAgICAgICAgY2FzZSAnNic6IHZhbCA9IDY7IGJyZWFrOworICAgICAgICAgICAgY2FzZSAnNSc6IHZhbCA9IDU7IGJyZWFrOworICAgICAgICAgICAgY2FzZSAnNCc6IHZhbCA9IDQ7IGJyZWFrOworICAgICAgICAgICAgY2FzZSAnMyc6IHZhbCA9IDM7IGJyZWFrOworICAgICAgICAgICAgY2FzZSAnMic6IHZhbCA9IDI7IGJyZWFrOworICAgICAgICAgICAgY2FzZSAnMSc6IHZhbCA9IDE7IGJyZWFrOworICAgICAgICAgICAgY2FzZSAnMCc6IHZhbCA9IDA7IGJyZWFrOworICAgICAgICAgICAgZGVmYXVsdDogcmV0dXJuIC1FSU5WQUw7CisgICAgICAgICAgICAgICAgLy8gY2xhbmctZm9ybWF0IG9uCiAgICAgICAgIH0KIAogICAgICAgICBpZiAoZXZlbikgewpAQCAtNDc4LDcgKzQ3OSw3IEBACiB1aW50NjRfdCBHZXRGcmVlQnl0ZXMoY29uc3Qgc3RkOjpzdHJpbmcmIHBhdGgpIHsKICAgICBzdHJ1Y3Qgc3RhdHZmcyBzYjsKICAgICBpZiAoc3RhdHZmcyhwYXRoLmNfc3RyKCksICZzYikgPT0gMCkgewotICAgICAgICByZXR1cm4gKHVpbnQ2NF90KSBzYi5mX2JhdmFpbCAqIHNiLmZfZnJzaXplOworICAgICAgICByZXR1cm4gKHVpbnQ2NF90KXNiLmZfYmF2YWlsICogc2IuZl9mcnNpemU7CiAgICAgfSBlbHNlIHsKICAgICAgICAgcmV0dX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plICs9IHN0YXRfc2l6ZSgmcyk7CiAgICAgICAgIH0KQEAgLTUyMywxMCArNTI0LDggQEAKIAogICAgICAgICAgICAgLyogYWx3YXlzIHNraXAgIi4iIGFuZCAiLi4iICovCiAgICAgICAgICAgICBpZiAobmFtZVswXSA9PSAnLicpIHsKLSAgICAgICAgICAgICAgICBpZiAobmFtZVsxXSA9PSAwKQotICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKLSAgICAgICAgICAgICAgICBpZiAoKG5hbWVbMV0gPT0gJy4nKSAmJiAobmFtZVsyXSA9PSAwKSkKLSAgICAgICAgICAgICAgICAgICAgY29udGludWU7CisgICAgICAgICAgICAgICAgaWYgKG5hbWVbMV0gPT0gMCkgY29udGludWU7CisgICAgICAgICAgICAgICAgaWYgKChuYW1lWzFdID09ICcuJykgJiYgKG5hbWVbMl0gPT0gMCkpIGNvbnRpbnVlOwogICAgICAgICAgICAgfQogCiAgICAgICAgICAgICBzdWJmZCA9IG9wZW5hdChkZmQsIG5hbWUsIE9fUkRPTkxZIHwgT19ESVJFQ1RPUlkgfCBPX0NMT0VYRUMpOwpAQCAtNTc2LDcgKzU3NSw3IEBACiAgICAgfQogCiAgICAgcmFuZ2VbMF0gPSAwOwotICAgIHJhbmdlWzFdID0gKHVuc2lnbmVkIGxvbmcgbG9uZykgbnJfc2VjICogNTEyOworICAgIHJhbmdlWzFdID0gKHVuc2lnbmVkIGxvbmcgbG9uZylucl9zZWMgKiA1MTI7CiAKICAgICBMT0coSU5GTykgPDwgIkFib3V0IHRvIGRpc2NhcmQgIiA8PCByYW5nZVsxXSA8PCAiIG9uICIgPDwgcGF0aDsKICAgICBpZiAoaW9jdGwoZmQsIEJMS0RJU0NBUkQsICZyYW5nZSkgPT0gMCkgewpAQCAtNTkyLDggKzU5MSw3IEBACiB9CiAKIHN0YXRpYyBib29sIGlzVmFsaWRGaWxlbmFtZShjb25zdCBzdGQ6OnN0cmluZyYgbmFtZSkgewotICAgIGlmIChuYW1lLmVtcHR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2JqZWN0IHVzaW5nIHRoZSBrZXltYXN0ZXIga2V5LiAqLwotc3RhdGljIGludCBrZXltYXN0ZXJfc2lnbl9vYmplY3Qoc3RydWN0IGNyeXB0X21udF9mdHIgKmZ0ciwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHVuc2lnbmVkIGNoYXIgKm9iamVjdCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNpemVfdCBvYmplY3Rfc2l6ZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGNoYXIgKipzaWduYXR1cmUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplX3QgKnNpZ25hdHVyZV9zaXplKQoteworc3RhdGljIGludCBrZXltYXN0ZXJfc2lnbl9vYmplY3Qoc3RydWN0IGNyeXB0X21udF9mdHIqIGZ0ciwgY29uc3QgdW5zaWduZWQgY2hhciogb2JqZWN0LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2l6ZV90IG9iamVjdF9zaXplLCB1bnNpZ25lZCBjaGFyKiogc2lnbmF0dXJlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90KiBzaWduYXR1cmVfc2l6ZSkgewogICAgIHVuc2lnbmVkIGNoYXIgdG9fc2lnbltSU0FfS0VZX1NJWkVfQllURVNdOwogICAgIHNpemVfdCB0b19zaWduX3NpemUgPSBzaXplb2YodG9fc2lnbik7CiAgICAgbWVtc2V0KHRvX3NpZ24sIDAsIFJTQV9LRVlfU0laRV9CWVRFUyk7CkBAIC0yMzAsMjEgKzIyMywyMCBAQAogc3RhdGljIGludCBwYXNzd29yZF9leHBpcnlfdGltZSA9IDA7CiBzdGF0aWMgY29uc3QgaW50IHBhc3N3b3JkX21heF9hZ2Vfc2Vjb25kcyA9IDYwOwogCi1lbnVtIGNsYXNzIFJlYm9vdFR5cGUge3JlYm9vdCwgcmVjb3ZlcnksIHNodXRkb3dufTsKLXN0YXRpYyB2b2lkIGNyeXB0ZnNfcmVib290KFJlYm9vdFR5cGUgcnQpCi17Ci0gIHN3aXRjaCAocnQpIHsKLSAgICAgIGNhc2UgUmVib290VHlwZTo6cmVib290OgotICAgICAgICAgIHByb3BlcnR5X3NldChBTkRST0lEX1JCX1BST1BFUlRZLCAicmVib290Iik7Ci0gICAgICAgICAgYnJlYWs7CitlbnVtIGNsYXNzIFJlYm9vdFR5cGUgeyByZWJvb3QsIHJlY292ZXJ5LCBzaHV0ZG93biB9Oworc3RhdGljIHZvaWQgY3J5cHRmc19yZWJvb3QoUmVib290VHlwZSBydCkgeworICAgIHN3aXRjaCAocnQpIHsKKyAgICAgICAgY2FzZSBSZWJvb3RUeXBlOjpyZWJvb3Q6CisgICAgICAgICAgICBwcm9wZXJ0eV9zZXQoQU5EUk9JRF9SQl9QUk9QRVJUWSwgInJlYm9vdCIpOworICAgICAgICAgICAgYnJlYWs7CiAKLSAgICAgIGNhc2UgUmVib290VHlwZTo6cmVjb3Zlcnk6Ci0gICAgICAgICAgcHJvcGVydHlfc2V0KEFORFJPSURfUkJfUFJPUEVSVFksICJyZWJvb3QscmVjb3ZlcnkiKTsKLSAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBSZWJvb3RUeXBlOjpyZWNvdmVyeToKKyAgICAgICAgICAgIHByb3BlcnR5X3NldChBTkRST0lEX1JCX1BST1BFUlRZLCAicmVib290LHJlY292ZXJ5Iik7CisgICAgICAgICAgICBicmVhazsKIAotICAgICAgY2FzZSBSZWJvb3RUeXBlOjpzaHV0ZG93bjoKLSAgICAgICAgICBwcm9wZXJ0eV9zZXQoQU5EUk9JRF9SQl9QUk9QRVJUWSwgInNodXRkb3duIik7Ci0gICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgUmVib290VHlwZTo6c2h1dGRvd246CisgICAgICAgICAgICBwcm9wZXJ0eV9zZXQoQU5EUk9JRF9SQl9QUk9QRVJ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HkoY2FjaGVkX21ldGFkYXRhX2ZuYW1lLCBrZXlfbG9jLCBzaXplb2YoY2FjaGVkX21ldGFkYXRhX2ZuYW1lKSk7Ci0gICAgICBjYWNoZWRfb2ZmID0gMDsKLSAgICAgIGNhY2hlZF9kYXRhID0gMTsKKyAgICAgICAgICAgIHVuc2lnbmVkIGxvbmcgbnJfc2VjID0gMDsKKyAgICAgICAgICAgIGdldF9ibGtkZXZfc2l6ZShmZCwgJm5yX3NlYyk7CisgICAgICAgICAgICBpZiAobnJfc2VjICE9IDApIHsKKyAgICAgICAgICAgICAgICAvKiBJZiBpdCdzIGFuIGVuY3J5cHRlZCBBbmRyb2lkIHBhcnRpdGlvbiwgdGhlIGxhc3QgMTYgS2J5dGVzIGNvbnRhaW4gdGhlCisgICAgICAgICAgICAgICAgICogZW5jcnlwdGlvbiBpbmZvIGZvb3RlciBhbmQga2V5LCBhbmQgcGxlbnR5IG9mIGJ5dGVzIHRvIHNwYXJlIGZvciBmdXR1cmUKKyAgICAgICAgICAgICAgICAgKiBncm93dGguCisgICAgICAgICAgICAgICAgICovCisgICAgICAgICAgICAgICAgc3RybGNweShjYWNoZWRfbWV0YWRhdGFfZm5hbWUsIHJlYWxfYmxrZGV2LCBzaXplb2YoY2FjaGVkX21ldGFkYXRhX2ZuYW1lKSk7CisgICAgICAgICAgICAgICAgY2FjaGVkX29mZiA9ICgob2ZmNjRfdClucl9zZWMgKiA1MTIpIC0gQ1JZUFRfRk9PVEVSX09GRlNFVDsKKyAgICAgICAgICAgICAgICBjYWNoZWRfZGF0YSA9IDE7CisgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgIFNMT0dFKCJDYW5ub3QgZ2V0IHNpemUgb2YgYmxvY2sgZGV2aWNlICVzXG4iLCByZWFsX2Jsa2Rldik7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBjbG9zZShmZCk7CisgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICBzdHJsY3B5KGNhY2hlZF9tZ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VkIGNoYXIqIGlrZXksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgdm9pZCogcGFyYW1zKSB7CiAgICAgU0xPR0koIlVzaW5nIHNjcnlwdCB3aXRoIGtleW1hc3RlciBmb3IgY3J5cHRmcyBLREYiKTsKIAogICAgIGludCByYzsKICAgICBzaXplX3Qgc2lnbmF0dXJlX3NpemU7CiAgICAgdW5zaWduZWQgY2hhciogc2lnbmF0dXJlOwotICAgIHN0cnVjdCBjcnlwdF9tbnRfZnRyICpmdHIgPSAoc3RydWN0IGNyeXB0X21udF9mdHIgKikgcGFyYW1zOworICAgIHN0cnVjdCBjcnlwdF9tbnRfZnRyKiBmdHIgPSAoc3RydWN0IGNyeXB0X21udF9mdHIqKXBhcmFtczsKIAogICAgIGludCBOID0gMSA8PCBmdHItPk5fZmFjdG9yOwogICAgIGludCByID0gMSA8PCBmdHItPnJfZmFjdG9yOwogICAgIGludCBwID0gMSA8PCBmdHItPnBfZmFjdG9yOwogCi0gICAgcmMgPSBjcnlwdG9fc2NyeXB0KChjb25zdCB1aW50OF90KilwYXNzd2QsIHN0cmxlbihwYXNzd2QpLAotICAgICAgICAgICAgICAgICAgICAgICBzYWx0LCBTQUxUX0xFTiwgTiwgciwgcCwgaWtleSwKKyAgICByYyA9IGNyeXB0b19zY3J5cHQoKGNvbnN0IHVpbnQ4X3QqKXBhc3N3ZCwgc3RybGVuKHBhc3N3ZCksIHNhbHQsIFNBTFRfTEVOLCBOLCByLCBwLCBpa2V5LAogICAgICAgICAgICAgICAgICAgICAgICBJTlRFUk1FRElBVEVfQlVGX1NJWkUpOwogCiAgICAgaWYgKHJjKSB7CkBAIC0xMjMxLDE0ICsxMTkwLDEzIEBACiAgICAgICAgIHJldHVybiAtMTsKICAgICB9CiAKLSAgICBpZiAoa2V5bWFzdGVyX3NpZ25fb2JqZWN0KGZ0ciwgaWtleSwgSU5URVJNRURJQVRFX0JVRl9TSVpFLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJnNpZ25hdHVyZSwgJnNpZ25hdHVyZV9zaXplKSkgeworICAgIGlmIChrZXltYXN0ZXJfc2lnbl9vYmplY3QoZnRyLCBpa2V5LCBJTlRFUk1FRElBVEVfQlVGX1NJWkUsICZzaWduYXR1cmUsICZzaWduYXR1cmVfc2l6ZSkpIHsKICAgICAgICAgU0xPR0UoIlNpZ25pbmcgZmFpbGVkIik7CiAgICAgICAgIHJldHVybiAtMTsKICAgICB9CiAKLSAgICByYyA9IGNyeXB0b19zY3J5cHQoc2lnbmF0dXJlLCBzaWduYXR1cmVfc2l6ZSwgc2FsdCwgU0FMVF9MRU4sCi0gICAgICAgICAgICAgICAgICAgICAgIE4sIHIsIHAsIGlrZXksIElOVEVSTUVESUFURV9CVUZfU0laRSk7CisgICAgcmMgPSBjcnlwdG9fc2NyeXB0KHNpZ25hdHVyZSwgc2lnbmF0dXJlX3NpemUsIHNhbHQsIFNBTFRfTEVOLCBOLCByLCBwLCBpa2V5LAorICAgICAgICAgICAgICAgICAgICAgICBJTlRFUk1FRElBVEVfQlVGX1NJWkUpOwogICAgIGZyZWUoc2lnbmF0dXJlKTsKIAogICAgIGlmIChyYykgewpAQCAtMTI0OSwxMiArMTIwNywxMCBAQAogICAgIHJldHVybiAwOwogfQogCi1zdGF0aWMgaW50IGVuY3J5cHRfbWFzdGVyX2tleShjb25zdCBjaGFyICpwYXNzd2QsIGNvbnN0IHVuc2lnbmVkIGNoYXIgKnNhbHQsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1bnNpZ25lZCBjaGFyICpkZWNyeXB0ZWRfbWFzdGVyX2tleSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGNoYXIgKmVuY3J5cHRlZF9tYXN0ZXJfa2V5LAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RydWN0IGNyeXB0X21udF9mdHIgKmNyeXB0X2Z0cikKLXsKLSAgICB1bnNpZ25lZCBjaGFyIGlrZXlbSU5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gICAgIHJldHVybiAtMTsKKyAgICAgICAgICAgIH0KIAotICAgICAgICBpZiAoc2NyeXB0X2tleW1hc3RlcihwYXNzd2QsIHNhbHQsIGlrZXksIGNyeXB0X2Z0cikpIHsKLSAgICAgICAgICAgIFNMT0dFKCJzY3J5cHQgZmFpbGVkIik7Ci0gICAgICAgICAgICByZXR1cm4gLTE7Ci0gICAgICAgIH0KLSAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBpZiAoc2NyeXB0X2tleW1hc3RlcihwYXNzd2QsIHNhbHQsIGlrZXksIGNyeXB0X2Z0cikpIHsKKyAgICAgICAgICAgICAgICBTTE9HRSgic2NyeXB0IGZhaWxlZCIpOworICAgICAgICAgICAgICAgIHJldHVybiAtMTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGJyZWFrOwogCi0gICAgY2FzZSBLREZfU0NSWVBUOgotICAgICAgICBpZiAoc2NyeXB0KHBhc3N3ZCwgc2FsdCwgaWtleSwgY3J5cHRfZnRyKSkgewotICAgICAgICAgICAgU0xPR0UoInNjcnlwdCBmYWlsZWQiKTsKLSAgICAgICAgICAgIHJldHVybiAtMTsKLSAgICAgICAgfQotICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBLREZfU0NSWVBUOgorICAgICAgICAgICAgaWYgKHNjcnlwdChwYXNzd2QsIHNhbHQsIGlrZXksIGNyeXB0X2Z0cikpIHsKKyAgICAgICAgICAgICAgICBTTE9HRSgic2NyeXB0IGZhaWxlZCIpOworICAgICAgICAgICAgICAgIHJldHVybiAtMTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGJyZWFrOwogCi0gICAgZGVmYXVsdDoKLSAgICAgICAgU0xPR0UoIkludmFsaWQga2RmX3R5cGUiKTsKLSAgICAgICAgcmV0dXJuIC0xOworICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgU0xPR0UoIkludmFsaWQga2RmX3R5cGUiKTsKKyAgICAgICAgICAgIHJldHVybiAtMTsKICAgICB9CiA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wdF9mdHItPmtleXNpemUpKSB7CiAgICAgICAgIFNMT0dFKCJFVlBfRW5jcnlwdFVwZGF0ZSBmYWlsZWRcbiIpOwogICAgICAgICByZXR1cm4gLTE7CiAgICAgfQotICAgIGlmICghIEVWUF9FbmNyeXB0RmluYWxfZXgoJmVfY3R4LCBlbmNyeXB0ZWRfbWFzdGVyX2tleSArIGVuY3J5cHRlZF9sZW4sICZmaW5hbF9sZW4pKSB7CisgICAgaWYgKCFFVlBfRW5jcnlwdEZpbmFsX2V4KCZlX2N0eCwgZW5jcnlwdGVkX21hc3Rlcl9rZXkgKyBlbmNyeXB0ZWRfbGVuLCAmZmluYWxfbGVuKSkgewogICAgICAgICBTTE9HRSgiRVZQX0VuY3J5cHRGaW5hbCBmYWlsZWRcbiIpOwogICAgICAgICByZXR1cm4gLTE7CiAgICAgfQpAQCAtMTMyMSwxMyArMTI3NywxMiBAQAogICAgIGludCByID0gMSA8PCBjcnlwdF9mdHItPnJfZmFjdG9yOwogICAgIGludCBwID0gMSA8PCBjcnlwdF9mdHItPnBfZmFjdG9yOwogCi0gICAgcmMgPSBjcnlwdG9fc2NyeXB0KGlrZXksIElOVEVSTUVESUFURV9LRVlfTEVOX0JZVEVTLAotICAgICAgICAgICAgICAgICAgICAgICBjcnlwdF9mdHItPnNhbHQsIHNpemVvZihjcnlwdF9mdHItPnNhbHQpLCBOLCByLCBwLAotICAgICAgICAgICAgICAgICAgICAgICBjcnlwdF9mdHItPnNjcnlwdGVkX2ludGVybWVkaWF0ZV9rZXksCisgICAgcmMgPSBjcnlwdG9fc2NyeXB0KGlrZXksIElOVEVSTUVESUFURV9LRVlfTEVOX0JZVEVTLCBjcnlwdF9mdHItPnNhbHQsIHNpemVvZihjcnlwdF9mdHItPnNhbHQpLAorICAgICAgICAgICAgICAgICAgICAgICBOLCByLCBwLCBjcnlwdF9mdHItPnNjcnlwdGVkX2ludGVybWVkaWF0ZV9rZXksCiAgICAgICAgICAgICAgICAgICAgICAgIHNpemVvZihjcnlwdF9mdHItPnNjcnlwdGVkX2ludGVybWVkaWF0ZV9rZXkpKTsKIAogICAgIGlmIChyYykgewotICAgICAgU0xPR0UoImVuY3J5cHRfbWFzdGVyX2tleTogY3J5cHRvX3NjcnlwdCBmYWlsZWQiKTsKKyAgICAgICAgU0xPR0UoImVuY3J5cHRfbWFzdGVyX2tleTogY3J5cHRvX3NjcnlwdCBmYWlsZWQiKTsKICAgICB9CiAKICAgICBFVlBfQ0lQSEVSX0NUWF9jbGVhbnVwKCZlX2N0eCk7CkBAIC0xMzM1LDYwICsxMjkwLDU3IEBACiAgICAgcmV0dXJuIDA7CiB9CiAKLXN0YXRpYyBpbnQgZGVjcnlwdF9tYXN0ZXJfa2V5X2F1eChjb25zdCBjaGFyICpwYXNzd2QsIHVuc2lnbmVkIGNoYXIgKnNhbHQsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdW5zaWduZWQgY2hhciAqZW5jcnlwdGVkX21hc3Rlcl9rZXksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90IGtleXNpemUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5zaWduZWQgY2hhciAqZGVjcnlwdGVkX21hc3Rlcl9rZXksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2RmX2Z1bmMga2RmLCB2b2lkICprZGZfcGFyYW1zLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGNoYXIqKiBpbnRlcm1lZGlhdGVfa2V5LAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemVfdCogaW50ZXJtZWRpYXRlX2tleV9zaXplKQotewotICB1bnNpZ25lZCBjaGFyIGlrZXlbSU5URVJNRURJQVRFX0JVRl9TSVpFXSA9IHsgMCB9OwotICBFVlBfQ0lQSEVSX0NUWCBkX2N0eDsKLSAgaW50IGRlY3J5cHRlZF9sZW4sIGZpbmFsX2xlbj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XB0X21udF9mdHIqIGZ0ciwga2RmX2Z1bmMqIGtkZiwgdm9pZCoqIGtkZl9wYXJhbXMpIHsKICAgICBpZiAoZnRyLT5rZGZfdHlwZSA9PSBLREZfU0NSWVBUX0tFWU1BU1RFUikgewogICAgICAgICAqa2RmID0gc2NyeXB0X2tleW1hc3RlcjsKICAgICAgICAgKmtkZl9wYXJhbXMgPSBmdHI7CkBAIC0xNDAxLDIwICsxMzUzLDE3IEBACiAgICAgfQogfQogCi1zdGF0aWMgaW50IGRlY3J5cHRfbWFzdGVyX2tleShjb25zdCBjaGFyICpwYXNzd2QsIHVuc2lnbmVkIGNoYXIgKmRlY3J5cHRlZF9tYXN0ZXJfa2V5LAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RydWN0IGNyeXB0X21udF9mdHIgKmNyeXB0X2Z0ciwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGNoYXIqKiBpbnRlcm1lZGlhdGVfa2V5LAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90KiBpbnRlcm1lZGlhdGVfa2V5X3NpemUpCi17CitzdGF0aWMgaW50IGRlY3J5cHRfbWFzdGVyX2tleShjb25zdCBjaGFyKiBwYXNzd2QsIHVuc2lnbmVkIGNoYXIqIGRlY3J5cHRlZF9tYXN0ZXJfa2V5LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RydWN0IGNyeXB0X21udF9mdHIqIGNyeXB0X2Z0ciwgdW5zaWduZWQgY2hhcioqIGludGVybWVkaWF0ZV9rZXksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplX3QqIGludGVybWVkaWF0ZV9rZXlfc2l6ZSkgewogICAgIGtkZl9mdW5jIGtkZjsKLSAgICB2b2lkICprZGZfcGFyYW1zOworICAgIHZvaWQqIGtkZl9wYXJhbXM7CiAgICAgaW50IHJldDsKIAogICAgIGdldF9rZGZfZnVuYyhjcnlwdF9mdHIsICZrZGYsICZr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GVkIGZpbGVzeXN0ZW0gbm90IHZhbGlkYXRlZCwgYWJvcnRpbmciKTsKICAgICAgICAgcmV0dXJuIC0xOwogICAgIH0KQEAgLTE1OTQsNyArMTUzNiw3IEBACiAgICAgICAgIHJldHVybiAtMTsKICAgICB9CiAKLSAgICBpZiAoISAocmMgPSB3YWl0X2FuZF91bm1vdW50KERBVEFfTU5UX1BPSU5ULCB0cnVlKSkgKSB7CisgICAgaWYgKCEocmMgPSB3YWl0X2FuZF91bm1vdW50KERBVEFfTU5UX1BPSU5ULCB0cnVlKSkpIHsKICAgICAgICAgLyogSWYgcm8uY3J5cHRvLnJlYWRvbmx5IGlzIHNldCB0byAxLCBtb3VudCB0aGUgZGVjcnlwdGVkCiAgICAgICAgICAqIGZpbGVzeXN0ZW0gcmVhZG9ubHkuICBUaGlzIGlzIHVzZWQgd2hlbiAvZGF0YSBpcyBtb3VudGVkIGJ5CiAgICAgICAgICAqIHJlY292ZXJ5IG1vZGUuCkBAIC0xNjE2LDE5ICsxNTU4LDE2IEBACiAgICAgICAgICAqIGZzX21ncl9kb19tb3VudCBydW5zIGZzY2suIFVzZSBzZXRleGVjY29uIHRvIHJ1biB0cnVzdGVkCiAgICAgICAgICAqIHBhcnRpdGlvbnMgaW4gdGhlIGZzY2sgZG9tYWluLgogICAgICAgICAgKi8KLSAgICAgICAgaWYgKHNldGV4ZWNjb24oc2Vjb250ZXh0RnNjaygpKSl7CisgICAgICAgIGlmIChzZXRleGVjY29uKHNlY29udGV4dEZzY2soKSkpIHsKICAgICAgICAgICAgIFNMT0dFKCJGYWlsZWQgdG8gc2V0ZXhlY2NvbiIpOwogICAgICAgICAgICAgcmV0dXJuIC0xOwogICAgICAgICB9Ci0gICAgICAgIHdoaWxlICgobW91bnRfcmMgPSBmc19tZ3JfZG9fbW91bnQoZnN0YWJfZGVmYXVsdCwgREFUQV9NTlRfUE9JTlQsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3J5cHRvX2Jsa2RldiwgMCkpCi0gICAgICAgICAgICAgICAhPSAwKSB7CisgICAgICAgIHdoaWxlICgobW91bnRfcmMgPSBmc19tZ3JfZG9fbW91bnQoZnN0YWJfZGVmYXVsdCwgREFUQV9NTlRfUE9JTlQsIGNyeXB0b19ibGtkZXYsIDApKSAhPSAwKSB7CiAgICAgICAgICAgICBpZiAobW91bnRfcmMgPT0gRlNfTUdSX0RPTU5UX0JVU1kpIHsKICAgICAgICAgICAgICAgICAvKiBUT0RPOiBpbnZva2Ugc29tZXRoaW5nIHNpbWlsYXIgdG8KICAgICAgICAgICAgICAgICAgICBQcm9jZXNzOjpraWxsUHJvY2Vzc1dpdGhPcGVuRmlsZXMoREFUQV9NTlRfUE9JTlQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHJpZXMgPiBSRVRSWV9NT1VOVF9BVFRFTVBULzIgPyAxIDogMiApICovCi0gICAgICAgICAgICAgICAgU0xPR0koIkZhaWxlZCB0byBtb3VudCAlcyBiZWNhdXNlIGl0IGlzIGJ1c3kgLSB3YWl0aW5nIiwKLSAgICAgICAgICAgICAgICAgICAgICBjcnlwdG9fYmxrZGV2KTsKKyAgICAgICAgICAgICAgICBTTE9HSSgiRmFpbGVkIHRvIG1vdW50ICVzIGJlY2F1c2UgaXQgaXMgYnVzeSAtIHdhaXRpbmciLCBjcnlwdG9fYmxrZGV2KTsKICAgICAgICAgICAgICAgICBpZiAoLS1yZXRyaWVzKSB7CiAgICAgICAgICAgICAgICAgICAgIHNsZWVwKFJFVFJZX01PVU5UX0RFTEFZX1NFQ09ORFMpOwogICAgICAgICAgICAgICAgIH0gZWxzZSB7CkBAIC0xNjcxLDggKzE2MTAsNyBAQAogICAgIHJldHVybiByYzsKIH0KIAotaW50IGNyeXB0ZnNfcmVzdGFydCh2b2lkKQoteworaW50IGNyeXB0ZnNfcmVzdGFydCh2b2lkKSB7CiAgICAgU0xPR0koImNyeXB0ZnNfcmVzdGFydCIpOwogICAgIG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lwdF9mdHIuZmxhZ3MgJiBDUllQVF9EQVRBX0NPUlJVUFQpewotICAgIFNMT0dFKCJFbmNyeXB0aW9uIGlzIHN1Y2Nlc3NmdWwgYnV0IGRhdGEgaXMgY29ycnVwdFxuIik7Ci0gICAgcmV0dXJuIENSWVBUT19DT01QTEVURV9DT1JSVVBUOwotICB9CisgICAgICAgIC8qCisgICAgICAgICAqIE9ubHkgcmVwb3J0IHRoaXMgZXJyb3IgaWYga2V5X2xvYyBpcyBhIGZpbGUgYW5kIGl0IGV4aXN0cy4KKyAgICAgICAgICogSWYgdGhlIGRldmljZSB3YXMgbmV2ZXIgZW5jcnlwdGVkLCBhbmQgL2RhdGEgaXMgbm90IG1vdW50YWJsZSBmb3IKKyAgICAgICAgICogc29tZSByZWFzb24sIHJldHVybmluZyAxIHNob3VsZCBwcmV2ZW50IHRoZSBVSSBmcm9tIHByZXNlbnRpbmcgdGhlCisgICAgICAgICAqIGEgImVudGVyIHBhc3N3b3JkIiBzY3JlZW4sIG9yIHdvcnNlLCBhICJwcmVzcyBidXR0b24gdG8gd2lwZSB0aGUKKyAgICAgICAgICogZGV2aWNlIiBzY3JlZW4uCisgICAgICAgICAqLworICAgICAgICBpZiAoKGtleV9sb2NbMF0gPT0gJy8nKSAmJiAoYWNjZXNzKCJrZXlfbG9jIiwgRl9PSykgPT0gLTEpKSB7CisgICAgICAgICAgICBTTE9HRSgibWFzdGVyIGtleSBmaWxlIGRvZXMgbm90IGV4aXN0LCBhYm9ydGluZyIpOworICAgICAgICAgICAgcmV0dXJuIENSWVBUT19DT01QTEVURV9OT1RfRU5DUllQVEVEOworICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgU0xPR0UoIkVycm9yIGdldHRpbmcgY3J5cHQgZm9vdGVyIGFuZCBrZXlcbiIpOworICAgICAgICAgICAgcmV0dXJuIENSWVBUT19DT01QTEVURV9CQURfTUVUQURBVEE7CisgICAgICAgIH0KKyAgICB9CiAKLSAgLyogV2UgcGFzc2VkIHRo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3Rlcl9rZXksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyeXB0X2Z0ci0+bWFzdGVyX2tleSwgY3J5cHRfZnRyKTsKLSAgICAgICAgaWYgKCFyYykgewotICAgICAgICAgICAgcmMgPSBwdXRfY3J5cHRfZnRyX2FuZF9rZXkoY3J5cHRfZnRyKTsKLSAgICAgICAgfQotICAgICAgICBTTE9HRCgiS2V5IERlcml2YXRpb24gRnVuY3Rpb24gdXBncmFkZTogcmM9JWRcbiIsIHJjKTsKLQotICAgICAgICAvLyBEbyBub3QgZmFpbCBldmVuIGlmIHVwZ3JhZGUgZmFpbGVkIC0gbWFjaGluZSBpcyBib290YWJsZQotICAgICAgICAvLyBOb3RlIHRoYXQgaWYgdGhpcyBjb2RlIGlzIGV2ZXIgaGl0LCB0aGVyZSBpcyBhICpzZXJpb3VzKiBwcm9ibGVtCi0gICAgICAgIC8vIHNpbmNlIEtERnMgc2hvdWxkIG5ldmVyIGZhaWwuIFlvdSAqbXVzdCogZml4IHRoZSBrZGYgYmVmb3JlCi0gICAgICAgIC8vIHByb2NlZWRpbmchCi0gICAgICAgIGlmIChyYykgewotICAgICAgICAgIFNMT0dXKCJVcGdyYWRlIGZhaWxlZCB3aXRoIGVycm9yICVkLCIKLSAgICAgICAgICAgICAgICAiIGJ1dCBjb250aW51aW5nIHdpdGggcHJldmlvdXMgc3RhdGUiLAotICAgICAgICAgICAgICAgIHJjKTsKLSAgICAgICAgICByYyA9IDA7CisgICAgICAgICAgICByYyA9ICsrY3J5cHRfZnRyLT5mYWlsZWRfZGVjcnlwdF9jb3VudDsKKyAgICAgICAgICAgIHB1dF9jcnlwdF9mdHJfYW5kX2tleShjcnlwdF9mdHIpOworICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgLyogU3VjY2VzcyEgKi8KKyAgICAgICAgICAgIFNMT0dJKCJQYXNzd29yZCBkaWQgbm90IG1hdGNoIGJ1dCBkZWNyeXB0ZWQgZHJpdmUgbW91bnRlZCA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CBjcnlwdF9mdHIpOworICAgICAgICAgICAgaWYgKCFyYykgeworICAgICAgICAgICAgICAgIHJjID0gcHV0X2NyeXB0X2Z0cl9hbmRfa2V5KGNyeXB0X2Z0cik7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBTTE9HRCgiS2V5IERlcml2YXRpb24gRnVuY3Rpb24gdXBncmFkZTogcmM9JWRcbiIsIHJjKTsKKworICAgICAgICAgICAgLy8gRG8gbm90IGZhaWwgZXZlbiBpZiB1cGdyYWRlIGZhaWxlZCAtIG1hY2hpbmUgaXMgYm9vdGFibGUKKyAgICAgICAgICAgIC8vIE5vdGUgdGhhdCBpZiB0aGlzIGNvZGUgaXMgZXZlciBoaXQsIHRoZXJlIGlzIGEgKnNlcmlvdXMqIHByb2JsZW0KKyAgICAgICAgICAgIC8vIHNpbmNlIEtERnMgc2hvdWxkIG5ldmVyIGZhaWwuIFlvdSAqbXVzdCogZml4IHRoZSBrZGYgYmVmb3JlCisgICAgICAgICAgICAvLyBwcm9jZWVkaW5nIQorICAgICAgICAgICAgaWYgKHJjKSB7CisgICAgICAgICAgICAgICAgU0xPR1coCisgICAgICAgICAgICAgICAgICAgICJVcGdyYWRlIGZhaWxlZCB3aXRoIGVycm9yICVkLCIKKyAgICAgICAgICAgICAgICAgICAgIiBidXQgY29udGludWluZyB3aXRoIHByZXZpb3VzIHN0YXRlIiwKKyAgICAgICAgICAgICAgICAgICAgcmMpOworICAgICAgICAgICAgICAgIHJjID0gMDsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgIH0KKworZXJyb3V0OgorICAgIGlmIChpbnRlcm1lZGlhdGVfa2V5KSB7CisgICAgICAgIG1lbXNldChpbnRlcm1lZGlhdGVfa2V5LCAwLCBpbnRlcm1lZGlhdGVfa2V5X3NpemUpOworICAgICAgICBmcmVlKGludGVybWVkaWF0ZV9rZXkpOworICAgIH0KKyAgICByZXR1cm4gcmM7CiB9CiAKIC8qCkBAIC0xODgwLDkgKzE4MTQsOSBAQA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MDYyLDE3ICsxOTkxLDE3IEBACiAgICAgZnRyLT5rZXlzaXplID0gY3J5cHRmc19nZXRfa2V5c2l6ZSgpOwogCiAgICAgc3dpdGNoIChrZXltYXN0ZXJfY2hlY2tfY29tcGF0aWJpbGl0eSgpKSB7Ci0gICAgY2FzZSAxOgotICAgICAgICBmdHItPmtkZl90eXBlID0gS0RGX1NDUllQVF9LRVlNQVNURVI7Ci0gICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIDE6CisgICAgICAgICAgICBmdHItPmtkZl90eXBlID0gS0RGX1NDUllQVF9LRVlNQVNURVI7CisgICAgICAgICAgICBicmVhazsKIAotICAgIGNhc2UgMDoKLSAgICAgICAgZnRyLT5rZGZfdHlwZSA9IEtERl9TQ1JZUFQ7Ci0gICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIDA6CisgICAgICAgICAgICBmdHItPmtkZl90eXBlID0gS0RGX1NDUllQVDsKKyAgICAgICAgICAgIGJyZWFrOwogCi0gICAgZGVmYXVsdDoKLSAgICAgICAgU0xPR0UoImtleW1hc3Rlcl9jaGVja19jb21wYXRpYmlsaXR5IGZhaWxlZCIpOwotICAgICAgICByZXR1cm4gLTE7CisgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICBTTE9HRSgia2V5bWFzdGVyX2NoZWNrX2NvbXBhdGliaWxpdHkgZmFpbGVkIik7CisgICAgICAgICAgICByZXR1cm4gLTE7CiAgICAgfQogCiAgICAgZ2V0X2RldmljZV9zY3J5cHRfcGFyYW1zKGZ0cik7CkBAIC0yMDgwLDggKzIwMDksNyBAQAogICAgIGZ0ci0+cGVyc2lzdF9kYXRhX3NpemUgPSBDUllQVF9QRVJTSVNUX0RBVEFfU0laRTsKICAgICBpZiAoZ2V0X2NyeXB0X2Z0cl9pbmZvKE5VTEwsICZvZmYpID09IDApIHsKICAgICAgICAgZnRyLT5wZXJzaXN0X2RhdGFfb2Zmc2V0WzBdID0gb2ZmICsgQ1JZUFRfRk9PVEVSX1RPX1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gewogICAgICAgICBTTE9HRSgiY3J5cHRmc19jaGFuZ2VwdyBub3QgdmFsaWQgZm9yIGZpbGUgZW5jcnlwdGlvbiIpOwogICAgICAgICByZXR1cm4gLTE7CkBAIC0yNTMyLDEyICsyNDU3LDggQEAKIAogICAgIGNyeXB0X2Z0ci5jcnlwdF90eXBlID0gY3J5cHRfdHlwZTsKIAotICAgIHJjID0gZW5jcnlwdF9tYXN0ZXJfa2V5KGNyeXB0X3R5cGUgPT0gQ1JZUFRfVFlQRV9ERUZBVUxUID8gREVGQVVMVF9QQVNTV09SRAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6IG5ld3B3LAotICAgICAgICAgICAgICAgICAgICAgICBjcnlwdF9mdHIuc2FsdCwKLSAgICAgICAgICAgICAgICAgICAgICAgc2F2ZWRfbWFzdGVyX2tleSwKLSAgICAgICAgICAgICAgICAgICAgICAgY3J5cHRfZnRyLm1hc3Rlcl9rZXksCi0gICAgICAgICAgICAgICAgICAgICAgICZjcnlwdF9mdHIpOworICAgIHJjID0gZW5jcnlwdF9tYXN0ZXJfa2V5KGNyeXB0X3R5cGUgPT0gQ1JZUFRfVFlQRV9ERUZBVUxUID8gREVGQVVMVF9QQVNTV09SRCA6IG5ld3B3LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyeXB0X2Z0ci5zYWx0LCBzYXZlZF9tYXN0ZXJfa2V5LCBjcnlwdF9mdHIubWFzdGVyX2tleSwgJmNyeXB0X2Z0cik7CiAgICAgaWYgKHJjKSB7CiAgICAgICAgIFNMT0dFKCJFbmNyeXB0IG1hc3RlciBrZXkgZmFpbGVkOiAlZCIsIHJjKTsKICAgICAgICAgcmV0dXJuIC0xOwpAQCAtMjU2NSwxNCArMjQ4NiwxMyBAQAogICAgICAgICBkc2l6ZSA9IENSWVBUX1BFUlNJU1RfREFUQV9TSVpFOwogICAgIH0KIAotICAgIG1heF9wZXJzaXN0ZW50X2VudHJpZXM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19zZXRmaWVsZCB3b3VsZCBub3QgYWxsb3cgZmllbGRzIHdpdGggbG9uZ2VyIG5hbWVzIHRvIGJlCkBAIC0yNzUzLDExICsyNjY5LDExIEBACiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBpZiAoIXBlcnNpc3RfZ2V0X2tleSh0ZW1wX2ZpZWxkLCB0ZW1wX3ZhbHVlKSkgewotICAgICAgICAgICAgICAgICAgaWYgKHN0cmxjYXQodmFsdWUsIHRlbXBfdmFsdWUsIGxlbikgPj0gKHVuc2lnbmVkKWxlbikgewotICAgICAgICAgICAgICAgICAgICAgIC8vIHZhbHVlIHRvbyBzbWFsbC4KLSAgICAgICAgICAgICAgICAgICAgICByYyA9IENSWVBUT19HRVRGSUVMRF9FUlJPUl9CVUZfVE9PX1NNQUxMOwotICAgICAgICAgICAgICAgICAgICAgIGdvdG8gb3V0OwotICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGlmIChzdHJsY2F0KHZhbHVlLCB0ZW1wX3ZhbHVlLCBsZW4pID49ICh1bnNpZ25lZClsZW4pIHsKKyAgICAgICAgICAgICAgICAgICAgLy8gdmFsdWUgdG9vIHNtYWxsLgorICAgICAgICAgICAgICAgICAgICByYyA9IENSWVBUT19HRVRGSUVMRF9FUlJPUl9CVUZfVE9PX1NNQUxMOworICAgICAgICAgICAgICAgICAgICBnb3RvIG91dDsKKyAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgIC8vIEV4aGF1c3QgYWxsIGVudHJpZXMuCiAgICAgICAgICAgICAgICAgYnJlYWs7CkBAIC0yNzczLDggKzI2ODksNyBAQAogfQogCiAvKiBTZXQgdGhlIHZhbHVlIG9mIHRoZSBzcGVjaWZpZWQgZmllbGQuICovCi1pbnQgY3J5cHRmc19zZXRmaWVsZChjb25zdCBjaGFyICpmaWVsZG5hbWUsIGNvbnN0IGNoYXIgKnZhbHV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nRpdGlvbiBpcyBub3QgZW5jcnlwdGVkLiAqLwotI2RlZmluZSBDUllQVF9FTkNSWVBUSU9OX0lOX1BST0dSRVNTIDB4MiAvKiBFbmNyeXB0aW9uIHBhcnRpYWxseSBjb21wbGV0ZWQsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVuY3J5cHRlZF91cHRvIHZhbGlkKi8KLSNkZWZpbmUgQ1JZUFRfSU5DT05TSVNURU5UX1NUQVRFIDB4NCAvKiBTZXQgd2hlbiBzdGFydGluZyBlbmNyeXB0aW9uLCBjbGVhciB3aGVuCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXhpdCBjbGVhbmx5LCBlaXRoZXIgdGhyb3VnaCBzdWNjZXNzIG9yCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29ycmVjdGx5IG1hcmtlZCBwYXJ0aWFsIGVuY3J5cHRpb24gKi8KLSNkZWZpbmUgQ1JZUFRfREFUQV9DT1JSVVBUIDB4OCAvKiBTZXQgd2hlbiBlbmNyeXB0aW9uIGlzIGZpbmUsIGJ1dCB0aGUKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bmRlcmx5aW5nIHZvbHVtZSBpcyBjb3JydXB0ICovCi0jZGVmaW5lIENSWVBUX0ZPUkNFX0VOQ1JZUFRJT04gMHgxMCAvKiBTZXQgd2hlbiBpdCBpcyB0aW1lIHRvIGVuY3J5cHQgdGhpcwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdm9sdW1lIG9uIGJvb3QuIEV2ZXJ5dGhpbmcgaW4gdGhpcwotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RydWN0dXJlIGlzIHNldCB1cCBjb3JyZWN0bHkgYXMKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRob3VnaCBkZXZpY2UgaXMgZW5jcnlwdGVkIGV4Y2VwdAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhhdCB0aGUgbWFzdGVyIGtleSBpcyBlbmNyeXB0ZWQgd2l0aCB0aGUKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQgcGFzc3dvcmQuICovCi0jZGVmaW5lIENSWVBUX0ZPUkNFX0NPTVBMRVRFIDB4MjAgLyogU2V0IHdoZW4gdGhlIGFib3ZlIGVuY3J5cHRpb24gY3ljbGUgaXMKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21wbGV0ZS4gT24gbmV4dCBjcnlwdGtlZXBlciBlbnRyeSwgbWF0Y2gKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGUgcGFzc3dvcmQuIElmIGl0IG1hdGNoZXMgZml4IHRoZSBtYXN0ZXIKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZXkgYW5kIHJlbW92ZSB0aGlzIGZsYWcuICovCisjZGVmaW5lIENSWVBUX0VOQ1JZUFRJT05fSU5fUFJPR1JFU1MgICAgICAgXAorICAgIDB4MiAvKiBFbmNyeXB0aW9uIHBhcnRpYWxseSBjb21wbGV0ZWQsIFwKKyAgICAgICAgICAgZW5jcnlwdGVkX3VwdG8gdmFsaWQqLworI2RlZmluZSBDUllQVF9JTkNPTlNJU1RFTlRfU1RBVEUgICAgICAgICAgICAgICAgICAgIFwKKyAgICAweDQgLyogU2V0IHdoZW4gc3RhcnRpbmcgZW5jcnlwdGlvbiwgY2xlYXIgd2hlbiBcCisgICAgICAgICAgIGV4aXQgY2xlYW5seSwgZWl0aGVyIHRocm91Z2ggc3VjY2VzcyBvciAgXAorICAgICAgICAgICBjb3JyZWN0bHkgbWFya2VkIHBhcnRpYWwgZW5jcnlwdGlvbiAqLworI2RlZmluZSBDUllQVF9EQVRBX0NPUlJVUFQgICAgICAgICAgICAgICAgICAgICAgXAorICAgIDB4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SBpcyBlbmNyeXB0ZWQgd2l0aCBhIHBhc3N3b3JkCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKiBNdXN0IGJlIHplcm8gdG8gYmUgY29tcGF0aWJsZSB3aXRoIHByZS1MCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKiBkZXZpY2VzIHdoZXJlIHR5cGUgaXMgYWx3YXlzIHBhc3N3b3JkLiovCi0jZGVmaW5lIENSWVBUX1RZUEVfREVGQVVMVCAgMSAvKiBtYXN0ZXJfa2V5IGlzIGVuY3J5cHRlZCB3aXRoIGRlZmF1bHQKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqIHBhc3N3b3JkICovCi0jZGVmaW5lIENSWVBUX1RZUEVfUEFUVEVSTiAgMiAvKiBtYXN0ZXJfa2V5IGlzIGVuY3J5cHRlZCB3aXRoIGEgcGF0dGVybiAqLwotI2RlZmluZSBDUllQVF9UWVBFX1BJTiAgICAgIDMgLyogbWFzdGVyX2tleSBpcyBlbmNyeXB0ZWQgd2l0aCBhIHBpbiAqLworI2RlZmluZSBDUllQVF9UWVBFX1BBU1NXT1JEICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgMCAvKiBtYXN0ZXJfa2V5IGlzIGVuY3J5cHRlZCB3aXRoIGEgcGFzc3dvcmQgIFwKKyAgICAgICAqIE11c3QgYmUgemVybyB0byBiZSBjb21wYXRpYmxlIHdpdGggcHJlLUwgXAorICAgICAgICogZGV2aWNlcyB3aGVyZSB0eXBlIGlzIGFsd2F5cyBwYXNzd29yZC4qLworI2RlZmluZSBDUllQVF9UWVBFX0RFRkFVTFQgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgIDEgICAgICAgICAgICAgICAgICAgICAgICAvKiBtYXN0ZXJfa2V5IGlzIGVuY3J5cHRlZCB3aXRoIGRlZmF1bHQgXAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKiBwYXNzd29yZCAqLworI2RlZmlu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OyAgLyogQWJzb2x1dGUgb2Zmc2V0IHRvIGJvdGggY29waWVzIG9mIGNyeXB0X3BlcnNpc3RfZGF0YQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqIG9uIGRldmljZSB3aXRoIHRoYXQgaW5mbywgZWl0aGVyIHRoZSBmb290ZXIgb2YgdGhlCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICogcmVhbF9ibGtkZXZpY2Ugb3IgdGhlIG1ldGFkYXRhIHBhcnRpdGlvbi4gKi8KKyAgICBfX2xlMzIgbWFnaWM7IC8qIFNlZSBhYm92ZSAqLworICAgIF9fbGUxNiBtYWpvcl92ZXJzaW9uOworICAgIF9fbGUxNiBtaW5vcl92ZXJzaW9uOworICAgIF9fbGUzMiBmdHJfc2l6ZTsgICAgICAgICAgICAgLyogaW4gYnl0ZXMsIG5vdCBpbmNsdWRpbmcga2V5IGZvbGxvd2luZyAqLworICAgIF9fbGUzMiBmbGFnczsgICAgICAgICAgICAgICAgLyogU2VlIGFib3ZlICovCisgICAgX19sZTMyIGtleXNpemU7ICAgICAgICAgICAgICAvKiBpbiBieXRlcyAqLworICAgIF9fbGUzMiBjcnlwdF90eXBlOyAgICAgICAgICAgLyogaG93IG1hc3Rlcl9rZXkgaXMgZW5jcnlwdGVkLiBNdXN0IGJlIGEKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqIENSWVBUX1RZUEVfWFhYIHZhbHVlICovCisgICAgX19sZTY0IGZzX3NpemU7ICAgICAgICAgICAgICAvKiBTaXplIG9mIHRoZSBlbmNyeXB0ZWQgZnMsIGluIDUxMiBieXRlIHNlY3RvcnMgKi8KKyAgICBfX2xlMzIgZmFpbGVkX2RlY3J5cHRfY291bnQ7IC8qIGNvdW50IG9mICMgb2YgZmFpbGVkIGF0dGVtcHRzIHRvIGRlY3J5cHQgYW5kCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb3VudCwgc2V0IHRvIDAgb24gc3VjY2Vzc2Z1bCBtb3VudCAqLworICAgIHVuc2lnbmVkIGNoYXIgY3J5cHRvX3R5cGVfbmFtZVtNQVhfQ1JZUFRPX1RZUEVfTkFNRV9MRU5dOyAvKiBUaGUgdHlwZSBvZiBlbmNyeXB0aW9uCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5lZWRlZCB0byBkZWNyeXB0IHRoaXMKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFydGl0aW9uLCBudWxsIHRlcm1pbmF0ZWQgKi8KKyAgICBfX2xlMzIgc3BhcmUyOyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogaWdub3JlZCAqLworICAgIHVuc2lnbmVkIGNoYXIgbWFzdGVyX2tleVtNQVhfS0VZX0xFTl07IC8qIFRoZSBlbmNyeXB0ZWQga2V5IGZvciBkZWNyeXB0aW5nIHRoZSBmaWxlc3lzdGVtICovCisgICAgdW5zaWduZWQgY2hhciBzYWx0W1NBTFRfTEVOXTsgICAgICAgICAgLyogVGhlIHNhbHQgdXNlZCBmb3IgdGhpcyBlbmNyeXB0aW9uICovCisgICAgX19sZTY0IHBlcnNpc3RfZGF0YV9vZmZzZXRbMl07ICAgICAgICAgLyogQWJzb2x1dGUgb2Zmc2V0IHRvIGJvdGggY29waWVzIG9mIGNyeXB0X3BlcnNpc3RfZGF0YQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqIG9uIGRldmljZSB3aXRoIHRoYXQgaW5mbywgZWl0aGVyIHRoZSBmb290ZXIgb2YgdGhlCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICogcmVhbF9ibGtkZXZpY2Ugb3IgdGhlIG1ldGFkYXRhIHBhcnRpdGlvbi4gKi8KIAotICBfX2xlMzIgcGVyc2lzdF9k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fTEVOR1RIXTsgLyogV2hlbiBDUllQVF9FTkNSWVBUSU9OX0lOX1BST0dSRVNTCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0LCBoYXNoIG9mIGZpcnN0IGJsb2NrLCB1c2VkCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG8gdmFsaWRhdGUgYmVmb3JlIGNvbnRpbnVpbmcqLworICAgIC8qIHNjcnlwdCBwYXJhbWV0ZXJzLiBTZWUgd3d3LnRhcnNuYXAuY29tL3NjcnlwdC9zY3J5cHQucGRmICovCisgICAgX19sZTggTl9mYWN0b3I7ICAgICAgICAvKiAoMSA8PCBOKSAqLworICAgIF9fbGU4IHJfZmFjdG9yOyAgICAgICAgLyogKDEgPDwgcikgKi8KKyAgICBfX2xlOCBwX2ZhY3RvcjsgICAgICAgIC8qICgxIDw8IHApICovCisgICAgX19sZTY0IGVuY3J5cHRlZF91cHRvOyAvKiBJZiB3ZSBhcmUgaW4gc3RhdGUgQ1JZUFRfRU5DUllQVElPTl9JTl9QUk9HUkVTUyBhbmQKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdlIGhhdmUgdG8gc3RvcCAoZS5nLiBwb3dlciBsb3cpIHRoaXMgaXMgdGhlIGxhc3QKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVuY3J5cHRlZCA1MTIgYnl0ZSBzZWN0b3IuKi8KKyAgICBfX2xlOCBoYXNoX2ZpcnN0X2Jsb2NrW1NIQTI1Nl9ESUdFU1RfTEVOR1RIXTsgLyogV2hlbiBDUllQVF9FTkNSWVBUSU9OX0lOX1BST0dSRVNTCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldCwgaGFzaCBvZiBmaXJzdCBibG9jaywgdXNlZAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA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8ICJGaWxlc3lzdGVtIGNoZWNrIGNvbXBsZXRlZCBPSyI7Ci0gICAgICAgICAgICByZXR1cm4gMDsKKyAgICAgICAgc3dpdGNoIChyYykgeworICAgICAgICAgICAgY2FzZSAwOgorICAgICAgICAgICAgICAgIExPRyhJTkZPKSA8PCAiRmlsZXN5c3RlbSBjaGVjayBjb21wbGV0ZWQgT0siOworICAgICAgICAgICAgICAgIHJldHVybiAwOwogCi0gICAgICAgIGNhc2UgMjoKLSAgICAgICAgICAgIExPRyhFUlJPUikgPDwgIkZpbGVzeXN0ZW0gY2hlY2sgZmFpbGVkIChub3QgYSBGQVQgZmlsZXN5c3RlbSkiOwotICAgICAgICAgICAgZXJybm8gPSBFTk9EQVRBOwotICAgICAgICAgICAgcmV0dXJuIC0xOworICAgICAgICAgICAgY2FzZSAyOgorICAgICAgICAgICAgICAgIExPRyhFUlJPUikgPDwgIkZpbGVzeXN0ZW0gY2hlY2sgZmFpbGVkIChub3QgYSBGQVQgZmlsZXN5c3RlbSkiOworICAgICAgICAgICAgICAgIGVycm5vID0gRU5PREFUQTsKKyAgICAgICAgICAgICAgICByZXR1cm4gLTE7CiAKLSAgICAgICAgY2FzZSA0OgotICAgICAgICAgICAgaWYgKHBhc3MrKyA8PSAzKSB7Ci0gICAgICAgICAgICAgICAgTE9HKFdBUk5JTkcpIDw8ICJGaWxlc3lzdGVtIG1vZGlmaWVkIC0gcmVjaGVja2luZyAocGFzcyAiIDw8IHBhc3MgPDwgIikiOwotICAgICAgICAgICAgICAgIGNvbnRpbnVlOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgTE9HKEVSUk9SKSA8PCAiRmFpbGluZyBjaGVjayBhZnRlciB0b28gbWFueSByZWNoZWNrcyI7Ci0gICAgICAgICAgICBlcnJubyA9IEVJTzsKLSAgICAgICAgICAgIHJldHVybiAtMTsKKyAgICAgICAgICAgIGNhc2UgNDoKKyAgICAgICAgICAgICAgICBpZiAocGFzcysrIDw9IDMpIHsKKyAgICAgICAgICAgICAgICAgICAgTE9HKFdBUk5JTkcpIDw8ICJGaWxlc3lzdGVtIG1vZGlmaWVkIC0gcmVjaGVja2luZyAocGFzcyAiIDw8IHBhc3MgPDwgIikiOworICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgTE9HKEVSUk9SKSA8PCAiRmFpbGluZyBjaGVjayBhZnRlciB0b28gbWFueSByZWNoZWNrcyI7CisgICAgICAgICAgICAgICAgZXJybm8gPSBFSU87CisgICAgICAgICAgICAgICAgcmV0dXJuIC0xOwogCi0gICAgICAgIGNhc2UgODoKLSAgICAgICAgICAgIExPRyhFUlJPUikgPDwgIkZpbGVzeXN0ZW0gY2hlY2sgZmFpbGVkIChubyBmaWxlc3lzdGVtKSI7Ci0gICAgICAgICAgICBlcnJubyA9IEVOT0RBVEE7Ci0gICAgICAgICAgICByZXR1cm4gLTE7CisgICAgICAgICAgICBjYXNlIDg6CisgICAgICAgICAgICAgICAgTE9HKEVSUk9SKSA8PCAiRmlsZXN5c3RlbSBjaGVjayBmYWlsZWQgKG5vIGZpbGVzeXN0ZW0pIjsKKyAgICAgICAgICAgICAgICBlcnJubyA9IEVOT0RBVEE7CisgICAgICAgICAgICAgICAgcmV0dXJuIC0xOwogCi0gICAgICAgIGRlZmF1bHQ6Ci0gICAgICAgICAgICBMT0coRVJST1IpIDw8ICJGaWxlc3lzdGVtIGNoZWNrIGZhaWxlZCAodW5rbm93biBleGl0IGNvZGUgIiA8PCByYyA8PCAiKSI7Ci0gICAgICAgICAgICBlcnJubyA9IEVJTzsKLSAgICAgICAgICAgIHJldHVybiAtMTsKKyAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgTE9HKEVSUk9SKSA8PCAiRmlsZXN5c3RlbSBjaGVjayBmYWlsZWQgKHVua25vd24gZXhpdCBjb2RlICIgPDwgcmMgPDwgIikiOworICAgICAgICAgICAgICAgIGVycm5vID0gRUlPOworICAgICA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RpbnVlOworICAgICAgICBpZiAoZGUtPmRfbmFtZVswXSA9PSAnLicpIGNvbnRpbnVlOwogCi0gICAgICAgIGlmIChkZS0+ZF90eXBlICE9IERUX0RJUiAmJiBsdmwgPiAwKQotICAgICAgICAgICAgY29udGludWU7CisgICAgICAgIGlmIChkZS0+ZF90eXBlICE9IERUX0RJUiAmJiBsdmwgPiAwKSBjb250aW51ZTsKIAogICAgICAgICBmZCA9IG9wZW5hdChkZmQsIGRlLT5kX25hbWUsIE9fUkRPTkxZIHwgT19ESVJFQ1RPUlkgfCBPX0NMT0VYRUMpOwotICAgICAgICBpZihmZCA8IDApCi0gICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgaWYgKGZkIDwgMCkgY29udGludWU7CiAKICAgICAgICAgZDIgPSBmZG9wZW5kaXIoZmQpOwotICAgICAgICBpZihkMiA9PSAwKQorICAgICAgICBpZiAoZDIgPT0gMCkKICAgICAgICAgICAgIGNsb3NlKGZkKTsKICAgICAgICAgZWxzZSB7CiAgICAgICAgICAgICBkb19jb2xkYm9vdChkMiwgbHZsICsgMSk7CkBAIC0yMDUsMTAgKzIwMywxMCBAQAogICAgIH0KIH0KIAotc3RhdGljIHZvaWQgY29sZGJvb3QoY29uc3QgY2hhciAqcGF0aCkgeworc3RhdGljIHZvaWQgY29sZGJvb3QoY29uc3QgY2hhciogcGF0aCkgewogICAgIEFUUkFDRV9OQU1FKCJjb2xkYm9vdCIpOwotICAgIERJUiAqZCA9IG9wZW5kaXIocGF0aCk7Ci0gICAgaWYoZCkgeworICAgIERJUiogZCA9IG9wZW5kaXIocGF0aCk7CisgICAgaWYgKGQpIHsKICAgICAgICAgZG9fY29sZGJvb3QoZCwgMCk7CiAgICAgICAgIGNsb3NlZGlyKGQpOwogICAgIH0KQEAgLTI1MSwxMyArMjQ5LDEzIEBACiAgICAgICAgICAgICAgICAgZmxhZ3MgfD0gYW5kcm9pZDo6dm9sZDo6RGlzazo6RmxhZ3M6OmtBZG9wdGFibGU7Ci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gICAgICAgY2FzZSAweDAwMDAxYjogbUxhYmVsID0gIlNhbXN1bmciOyBicmVhazsKLSAgICAgICAgY2FzZSAweDAwMDAyODogbUxhYmVsID0gIkxleGFyIjsgYnJlYWs7Ci0gICAgICAgIGNhc2UgMHgwMDAwNzQ6IG1MYWJlbCA9ICJUcmFuc2NlbmQiOyBicmVhazsKLSAgICAgICAgfQotICAgICAgICBicmVhazsKLSAgICB9Ci0gICAgZGVmYXVsdDogewotICAgICAgICBpZiAoaXNWaXJ0aW9CbGtEZXZpY2UobWFqb3JJZCkpIHsKLSAgICAgICAgICAgIExPRyhERUJVRykgPDwgIlJlY29nbml6ZWQgZXhwZXJpbWVudGFsIGJsb2NrIG1ham9yIElEICIgPDwgbWFqb3JJZAotICAgICAgICAgICAgICAgICAgICA8PCAiIGFzIHZpcnRpby1ibGsgKGVtdWxhdG9yJ3MgdmlydHVhbCBTRCBjYXJkIGRldmljZSkiOworICAgICAgICBjYXNlIGtNYWpvckJsb2NrTG9vcDogewogICAgICAgICAgICAgbUxhYmVsID0gIlZpcnR1YWwiOwogICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIH0KLSAgICAgICAgaWYgKGlzTnZtZUJsa0RldmljZShtYWpvcklkLCBtU3lzUGF0aCkpIHsKLSAgICAgICAgICAgIHN0ZDo6c3RyaW5nIHBhdGgobVN5c1BhdGggKyAiL2RldmljZS9tb2RlbCIpOworICAgICAgICAvLyBjbGFuZy1mb3JtYXQgb2ZmCisgICAgICAgIGNhc2Uga01ham9yQmxvY2tTY3NpQTogY2FzZSBrTWFqb3JCbG9ja1Njc2lCOiBjYXNlIGtNYWpvckJsb2NrU2NzaUM6CisgICAgICAgIGNhc2Uga01ham9yQmxvY2tTY3NpRDogY2FzZSBrTWFqb3JCbG9ja1Njc2lFOiBjYXNlIGtNYWpvckJsb2NrU2NzaUY6CisgICAgICAgIGNhc2Uga01ham9yQmxvY2tTY3NpRzogY2FzZSBrTWFqb3JCbG9ja1Njc2lIOiBjYX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gIGlmICghUmVhZEZpbGVUb1N0cmluZyhwYXRoLCAmdG1wKSkgeworICAgICAgICAgICAgICAgIFBMT0coV0FSTklORykgPDwgIkZhaWxlZCB0byByZWFkIG1hbnVmYWN0dXJlciBmcm9tICIgPDwgcGF0aDsKKyAgICAgICAgICAgICAgICByZXR1cm4gLWVycm5vOworICAgICAgICAgICAgfQorICAgICAgICAgICAgdG1wID0gYW5kcm9pZDo6YmFzZTo6VHJpbSh0bXApOworICAgICAgICAgICAgaW50NjRfdCBtYW5maWQ7CisgICAgICAgICAgICBpZiAoIWFuZHJvaWQ6OmJhc2U6OlBhcnNlSW50KHRtcCwgJm1hbmZpZCkpIHsKKyAgICAgICAgICAgICAgICBQTE9HKFdBUk5JTkcpIDw8ICJGYWlsZWQgdG8gcGFyc2UgbWFudWZhY3R1cmVyICIgPDwgdG1wOworICAgICAgICAgICAgICAgIHJldHVybiAtRUlOVkFMOworICAgICAgICAgICAgfQorICAgICAgICAgICAgLy8gT3VyIGdvYWwgaGVyZSBpcyB0byBnaXZlIHRoZSB1c2VyIGEgbWVhbmluZ2Z1bCBsYWJlbCwgaWRlYWxseQorICAgICAgICAgICAgLy8gbWF0Y2hpbmcgd2hhdGV2ZXIgaXMgc2lsay1zY3JlZW5lZCBvbiB0aGUgY2FyZC4gIFRvIHJlZHVjZQorICAgICAgICAgICAgLy8gdXNlciBjb25mdXNpb24sIHRoaXMgbGlzdCBkb2Vzbid0IGNvbnRhaW4gd2hpdGUtbGFiZWwgbWFuZmlkLgorICAgICAgICAgICAgc3dpdGNoIChtYW5maWQpIHsKKyAgICAgICAgICAgICAgICAvLyBjbGFuZy1mb3JtYXQgb2ZmCisgICAgICAgICAgICAgICAgY2FzZSAweDAwMDAwMzogbUxhYmVsID0gIlNhbkRpc2siOyBicmVhazsKKyAgICAgICAgICAgICAgICBjYXNlIDB4MDAwMDFiOiBtTGFiZWwgPSAiU2Ftc3VuZyI7IGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgMHgwMDAwMjg6IG1MYWJlbCA9ICJMZXhhciI7IGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgMHgwMDAwNzQ6IG1MYWJlbCA9ICJUcmFuc2NlbmQiOyBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgLy8gY2xhbmctZm9ybWF0IG9uCisgICAgICAgICAgICB9CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorICAgICAgICBkZWZhdWx0OiB7CisgICAgICAgICAgICBpZiAoaXNWaXJ0aW9CbGtEZXZpY2UobWFqb3JJZCkpIHsKKyAgICAgICAgICAgICAgICBMT0coREVCVUcpIDw8ICJSZWNvZ25pemVkIGV4cGVyaW1lbnRhbCBibG9jayBtYWpvciBJRCAiIDw8IG1ham9ySWQKKyAgICAgICAgICAgICAgICAgICAgICAgICAgIDw8ICIgYXMgdmlydGlvLWJsayAoZW11bGF0b3IncyB2aXJ0dWFsIFNEIGNhcmQgZGV2aWNlKSI7CisgICAgICAgICAgICAgICAgbUxhYmVsID0gIlZpcnR1YWwiOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgfQorICAgICAgICAgICAgaWYgKGlzTnZtZUJsa0RldmljZShtYWpvcklkLCBtU3lzUGF0aCkpIHsKKyAgICAgICAgICAgICAgICBzdGQ6OnN0cmluZyBwYXRoKG1TeXNQYXRoICsgIi9kZXZpY2UvbW9kZWwiKTsKKyAgICAgICAgICAgICAgICBzdGQ6OnN0cmluZyB0bXA7CisgICAgICAgICAgICAgICAgaWYgKCFSZWFkRmlsZVRvU3RyaW5nKHBhdGgsICZ0bXApKSB7CisgICAgICAgICAgICAgICAgICAgIFBMT0coV0FSTklORykgPDwgIkZhaWxlZCB0byByZWFkIHZlbmRvciBmcm9tICIgPDwgcGF0aDsKKyAgICAgICAgICAgICAgICAgICAgcmV0dXJuIC1lcnJubzsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgbUxhYmVsID0gdG1wOworICAgICAgICAgICAgICAgIGJyZ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JCbG9ja1Njc2lPOgorICAgICAgICBjYXNlIGtNYWpvckJsb2NrU2NzaVA6IHsKKyAgICAgICAgICAgIC8vIGNsYW5nLWZvcm1hdCBvbgorICAgICAgICAgICAgLy8gUGVyIERvY3VtZW50YXRpb24vZGV2aWNlcy50eHQgdGhpcyBpcyBzdGF0aWMKICAgICAgICAgICAgIHJldHVybiAxNTsKICAgICAgICAgfQotICAgICAgICBpZiAoaXNOdm1lQmxrRGV2aWNlKG1ham9ySWQsIG1TeXNQYXRoKSkgewotICAgICAgICAgICAgLy8gZGVzcGl0ZSBrZXJuZWwgbnZtZSBkcml2ZXIgc3VwcG9ydHMgdXAgdG8gMU0gbWlub3JzLAotICAgICAgICAgICAgLy8gICAgICNkZWZpbmUgTlZNRV9NSU5PUlMgKDFVIDw8IE1JTk9SQklUUykKLSAgICAgICAgICAgIC8vIHNnZGlzayBjYW4gbm90IHN1cHBvcnQgbW9yZSB0aGFuIDEyNyBwYXJ0aXRpb25zLCBkdWUgdG8KLSAgICAgICAgICAgIC8vICAgICAjZGVmaW5lIE1BWF9NQlJfUEFSVFMgMTI4Ci0gICAgICAgICAgICByZXR1cm4gMTI3OworICAgICAgICBjYXNlIGtNYWpvckJsb2NrTW1jOiB7CisgICAgICAgICAgICAvLyBQZXIgRG9jdW1lbnRhdGlvbi9kZXZpY2VzLnR4dCB0aGlzIGlzIGR5bmFtaWMKKyAgICAgICAgICAgIHN0ZDo6c3RyaW5nIHRtcDsKKyAgICAgICAgICAgIGlmICghUmVhZEZpbGVUb1N0cmluZyhrU3lzZnNNbWNNYXhNaW5vcnMsICZ0bXApICYmCisgICAgICAgICAgICAgICAgIVJlYWRGaWxlVG9TdHJpbmcoa1N5c2ZzTW1jTWF4TWlub3JzRGVwcmVjYXRlZCwgJnRtcCkpIHsKKyAgICAgICAgICAgICAgICBMT0coRVJST1IpIDw8ICJGYWlsZWQgdG8gcmVhZCBtYXggbWlub3JzIjsKKyAgICAgICAgICAgICAgICByZXR1cm4gLWVycm5vOworICAgICAgICAgICAgfQorICAgICAgICAgICAgcmV0dXJuIHN0ZDo6c3RvaSh0bXApOwogICAgICAgICB9Ci0gICAgfQorICAgICAgICBkZWZhdWx0OiB7CisgICAgICAgICAgICBpZiAoaXNWaXJ0aW9CbGtEZXZpY2UobWFqb3JJZCkpIHsKKyAgICAgICAgICAgICAgICAvLyBkcml2ZXJzL2Jsb2NrL3ZpcnRpb19ibGsuYyBoYXMgIiNkZWZpbmUgUEFSVF9CSVRTIDQiLCBzbyBtYXggaXMKKyAgICAgICAgICAgICAgICAvLyAyXjQgLSAxID0gMTUKKyAgICAgICAgICAgICAgICByZXR1cm4gMTU7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBpZiAoaXNOdm1lQmxrRGV2aWNlKG1ham9ySWQsIG1TeXNQYXRoKSkgeworICAgICAgICAgICAgICAgIC8vIGRlc3BpdGUga2VybmVsIG52bWUgZHJpdmVyIHN1cHBvcnRzIHVwIHRvIDFNIG1pbm9ycywKKyAgICAgICAgICAgICAgICAvLyAgICAgI2RlZmluZSBOVk1FX01JTk9SUyAoMVUgPDwgTUlOT1JCSVRTKQorICAgICAgICAgICAgICAgIC8vIHNnZGlzayBjYW4gbm90IHN1cHBvcnQgbW9yZSB0aGFuIDEyNyBwYXJ0aXRpb25zLCBkdWUgdG8KKyAgICAgICAgICAgICAgICAvLyAgICAgI2RlZmluZSBNQVhfTUJSX1BBUlRTIDEyOAorICAgICAgICAgICAgICAgIHJldHVybiAxMjc7CisgICAgICAgICAgICB9CisgICAgICAgIH0KICAgICB9CiAKICAgICBMT0coRVJST1IpIDw8ICJVbnN1cHBvcnRlZCBibG9jayBtYWpvciB0eXBlICIgPDwgbWFqb3JJZDsKZGlmZiAtLWdpdCBhL21vZGVsL0Rpc2suaCBiL21vZGVsL0Rpc2suaAppbmRleCA2M2FjZjZhLi4zMTQwMTQ0IDEwMDY0NAotLS0gYS9tb2RlbC9EaXNrLmgKKysrIGIvbW9kZWwvRGlzay5oCkBAIC0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zZTo6dW5pcXVlX2ZkIGZkKFRFTVBfRkFJTFVSRV9SRVRSWShvcGVuKHRhcmdldC5jX3N0cigpLCBPX1dST05MWSwgMCkpKTsKICAgICAgICAgaWYgKGZkID09IC0xKSB7CiAgICAgICAgICAgICBMT0coRVJST1IpIDw8ICJTZWN1cmUgZGlzY2FyZCBvcGVuIGZhaWxlZCBmb3I6ICIgPDwgdGFyZ2V0OwogICAgICAgICAgICAgcmV0dXJuIDA7CkBAIC0xMDIsMjkgKzEwMSwyOSBAQAogCiBuYW1lc3BhY2UgewogCi1ib29sIHJlYWRfY29tbWFuZF9saW5lKGludCBhcmdjLCBjb25zdCBjaGFyICogY29uc3QgYXJndltdLCBPcHRpb25zICZvcHRpb25zKSB7Citib29sIHJlYWRfY29tbWFuZF9saW5lKGludCBhcmdjLCBjb25zdCBjaGFyKiBjb25zdCBhcmd2W10sIE9wdGlvbnMmIG9wdGlvbnMpIHsKICAgICBmb3IgKGludCBpID0gMTsgaSA8IGFyZ2M7IGkrKykgewogICAgICAgICBpZiAoIXN0cmNtcCgiLS1uby11bmxpbmsiLCBhcmd2W2ldKSkgewogICAgICAgICAgICAgb3B0aW9ucy51bmxpbmsgPSBmYWxzZTsKICAgICAgICAgfSBlbHNlIGlmICghc3RyY21wKCItLSIsIGFyZ3ZbaV0pKSB7Ci0gICAgICAgICAgICBmb3IgKGludCBqID0gaSsxOyBqIDwgYXJnYzsgaisrKSB7Ci0gICAgICAgICAgICAgICAgaWYgKGFyZ3Zbal1bMF0gIT0gJy8nKSByZXR1cm4gZmFsc2U7IC8vIE11c3QgYmUgYWJzb2x1dGUgcGF0aAorICAgICAgICAgICAgZm9yIChpbnQgaiA9IGkgKyAxOyBqIDwgYXJnYzsgaisrKSB7CisgICAgICAgICAgICAgICAgaWYgKGFyZ3Zbal1bMF0gIT0gJy8nKSByZXR1cm4gZmFsc2U7ICAvLyBNdXN0IGJlIGFic29sdXRlIHBhdGgKICAgICAgICAgICAgICAgICBvcHRpb25zLnR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fUkFURV9MSU1JVCAxICAvLyBNYXhpbXVtIG9uZSB0cnkgcGVyIHNlY29uZAogCi1zdGF0aWMgaW50IGtleW1hc3Rlcl9pbml0KGtleW1hc3RlcjBfZGV2aWNlX3QgKiprZXltYXN0ZXIwX2RldiwKLSAgICAgICAgICAgICAgICAgICAgICAgICAga2V5bWFzdGVyMV9kZXZpY2VfdCAqKmtleW1hc3RlcjFfZGV2KQoteworc3RhdGljIGludCBrZXltYXN0ZXJfaW5pdChrZXltYXN0ZXIwX2RldmljZV90Kioga2V5bWFzdGVyMF9kZXYsCisgICAgICAgICAgICAgICAgICAgICAgICAgIGtleW1hc3RlcjFfZGV2aWNlX3QqKiBrZXltYXN0ZXIxX2RldikgewogICAgIGludCByYzsKIAogICAgIGNvbnN0IGh3X21vZHVsZV90KiBtb2Q7CkBAIC03Niw4ICs3NSw4IEBACiAgICAgfQogCiAgICAgaWYgKHJjKSB7Ci0gICAgICAgIEFMT0dFKCJjb3VsZCBub3Qgb3BlbiBrZXltYXN0ZXIgZGV2aWNlIGluICVzICglcykiLAotICAgICAgICAgICAgICBLRVlTVE9SRV9IQVJEV0FSRV9NT0RVTEVfSUQsIHN0cmVycm9yKC1yYykpOworICAgICAgICBBTE9HRSgiY291bGQgbm90IG9wZW4ga2V5bWFzdGVyIGRldmljZSBpbiAlcyAoJXMpIiwgS0VZU1RPUkVfSEFSRFdBUkVfTU9EVUxFX0lELAorICAgICAgICAgICAgICBzdHJlcnJvcigtcmMpKTsKICAgICAgICAgZ290byBlcnI7CiAgICAgfQogCkBAIC05MCwxMCArODksOSBAQAogfQogCiAvKiBTaG91bGQgd2UgdXNlIGtleW1hc3Rlcj8gKi8KLXN0YXRpYyBpbnQga2V5bWFzdGVyX2NoZWNrX2NvbXBhdGliaWxpdHlfb2xkKCkKLXsKLSAgICBrZXltYXN0ZXIwX2RldmljZV90ICprZXltYXN0ZXIwX2RldiA9IDA7Ci0gICAga2V5bWFzdGVyMV9kZXZpY2VfdCAqa2V5bW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lcjFfZGV2LCAmcGFyYW1fc2V0LAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJmtleV9ibG9iLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTlVMTCAvKiBjaGFyYWN0ZXJpc3RpY3MgKi8pOworICAgICAgICBrZXltYXN0ZXJfZXJyb3JfdCBlcnJvciA9IGtleW1hc3RlcjFfZGV2LT5nZW5lcmF0ZV9rZXkoCisgICAgICAgICAgICBrZXltYXN0ZXIxX2RldiwgJnBhcmFtX3NldCwgJmtleV9ibG9iLCBOVUxMIC8qIGNoYXJhY3RlcmlzdGljcyAqLyk7CiAgICAgICAgIGlmIChlcnJvciAhPSBLTV9FUlJPUl9PSykgewogICAgICAgICAgICAgU0xPR0UoIkZhaWxlZCB0byBnZW5lcmF0ZSBrZXltYXN0ZXIxIGtleSwgZXJyb3IgJWQiLCBlcnJvcik7CiAgICAgICAgICAgICByYyA9IC0xOwpAQCAtMTkwLDE1ICsxODUsMTMgQEAKIAogICAgICAgICBrZXkgPSAodWludDhfdCopa2V5X2Jsb2Iua2V5X21hdGVyaWFsOwogICAgICAgICBrZXlfc2l6ZSA9IGtleV9ibG9iLmtleV9tYXRlcmlhbF9zaXplOwotICAgIH0KLSAgICBlbHNlIGlmIChrZXltYXN0ZXIwX2RldikgeworICAgIH0gZWxzZSBpZiAoa2V5bWFzdGVyMF9kZXYpIHsKICAgICAgICAga2V5bWFzdGVyX3JzYV9rZXlnZW5fcGFyYW1zX3QgcGFyYW1zOwogICAgICAgICBtZW1zZXQoJnBhcmFtcywgJ1wwJywgc2l6ZW9mKHBhcmFtcykpOwogICAgICAgICBwYXJhbXMucHVibGljX2V4cG9uZW50ID0gUlNBX0VYUE9ORU5UOwogICAgICAgICBwYXJhbXMubW9kdWx1c19zaXplID0gUlNBX0tFWV9TSVpFOwogCi0gICAgICAgIGlmIChrZ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ICAgICAgICAgICAgICBjb25zdCB1bnNpZ25lZCBjaGFyICpvYmplY3QsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzaXplX3Qgb2JqZWN0X3NpemUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBjaGFyICoqc2lnbmF0dXJlLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90ICpzaWduYXR1cmVfc2l6ZSkKLXsKK3N0YXRpYyBpbnQga2V5bWFzdGVyX3NpZ25fb2JqZWN0X29sZChzdHJ1Y3QgY3J5cHRfbW50X2Z0ciogZnRyLCBjb25zdCB1bnNpZ25lZCBjaGFyKiBvYmplY3QsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2l6ZV90IG9iamVjdF9zaXplLCB1bnNpZ25lZCBjaGFyKiogc2lnbmF0dXJlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemVfdCogc2lnbmF0dXJlX3NpemUpIHsKICAgICBpbnQgcmMgPSAwOwotICAgIGtleW1hc3RlcjBfZGV2aWNlX3QgKmtleW1hc3RlcjBfZGV2ID0gMDsKLSAgICBrZXltYXN0ZXIxX2RldmljZV90ICprZXltYXN0ZXIxX2RldiA9IDA7CisgICAga2V5bWFzdGVyMF9kZXZpY2VfdCoga2V5bWFzdGVyMF9kZXYgPSAwOworICAgIGtleW1hc3RlcjFfZGV2aWNlX3QqIGtleW1hc3RlcjFfZGV2ID0gMDsKIAogICAgIHVuc2lnbmVkIGNoYXIgdG9fc2lnbltSU0FfS0VZX1NJWkVfQllURVNdOwogICAgIHNpemVfdCB0b19zaWduX3NpemUgPSBzaXplb2YodG9fc2lnbik7CkBAIC0yODQsMzIgKzI3MiwyNSBAQAogICAgICAgICBwYXJhbXMuZGlnZXN0X3R5cGUgPSBESUdFU1RfTk9ORTsKICAgICAgICAgcGFyYW1zLnBhZGRpbmdfdHlwZSA9IFBBRERJTkdfTk9ORTsKIAotICAgICAgICByYyA9IGtleW1hc3RlcjBfZGV2LT5zaWduX2RhdGEoa2V5bWFzdGVyMF9kZXYsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICZwYXJhbXMsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZ0ci0+a2V5bWFzdGVyX2Jsb2IsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZ0ci0+a2V5bWFzdGVyX2Jsb2Jfc2l6ZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG9fc2lnbiwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG9fc2lnbl9zaXplLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaWduYXR1cmUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpZ25hdHVyZV9zaXplKTsKKyAgICAgICAgcmMgPSBrZXltYXN0ZXIwX2Rldi0+c2lnbl9kYXRhKGtleW1hc3RlcjBfZGV2LCAmcGFyYW1zLCBmdHItPmtleW1hc3Rlcl9ibG9iLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnRyLT5rZXltYXN0ZXJfYmxvYl9zaXplLCB0b19zaWduLCB0b19zaWduX3NpemUsIHNpZ25hdHVyZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpZ25hdHVyZV9zaXplKTsKICAgICAgICAgZ290byBvdXQ7CiAgICAgfSBlbHNlIGlmIChrZXltYXN0ZXIxX2RldikgewotICAgICAgICBrZXltYXN0ZXJfa2V5X2Jsb2JfdCBrZXkgPSB7IGZ0ci0+a2V5bWFzdGVyX2Jsb2IsIGZ0ci0+a2V5bWFzdGVyX2Jsb2Jfc2l6ZSB9OworICAgICAgICBrZXltYXN0ZXJfa2V5X2Jsb2JfdCBrZXkg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1fc2V0LCBOVUxMIC8qIG91dF9wYXJhbXMgKi8sICZvcF9oYW5kbGUpOwogICAgICAgICBpZiAoZXJyb3IgPT0gS01fRVJST1JfS0VZX1JBVEVfTElNSVRfRVhDRUVERUQpIHsKICAgICAgICAgICAgIC8vIEtleSB1c2FnZSBoYXMgYmVlbiByYXRlLWxpbWl0ZWQuICBXYWl0IGEgYml0IGFuZCB0cnkgYWdhaW4uCiAgICAgICAgICAgICBzbGVlcChLRVlNQVNURVJfQ1JZUFRGU19SQVRFX0xJTUlUKTsKLSAgICAgICAgICAgIGVycm9yID0ga2V5bWFzdGVyMV9kZXYtPmJlZ2luKGtleW1hc3RlcjFfZGV2LCBLTV9QVVJQT1NFX1NJR04sICZrZXksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmcGFyYW1fc2V0LCBOVUxMIC8qIG91dF9wYXJhbXMgKi8sCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmb3BfaGFuZGxlKTsKKyAgICAgICAgICAgIGVycm9yID0ga2V5bWFzdGVyMV9kZXYtPmJlZ2luKGtleW1hc3RlcjFfZGV2LCBLTV9QVVJQT1NFX1NJR04sICZrZXksICZwYXJhbV9zZXQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBOVUxMIC8qIG91dF9wYXJhbXMgKi8sICZvcF9oYW5kbGUpOwogICAgICAgICB9CiAgICAgICAgIGlmIChlcnJvciAhPSBLTV9FUlJPUl9PSykgewogICAgICAgICAgICAgU0xPR0UoIkVycm9yIHN0YXJ0aW5nIGtleW1hc3RlciBzaWduYXR1cmUgdHJhbnNhY3Rpb246ICVkIiwgZXJyb3IpOwpAQCAtMzE3LDExICsyOTgsMTAgQEAKICAgICAgICAgICAgIGdvdG8gb3V0OwogICAgICAgICB9CiAKLSAgICAgICAga2V5bWFzdGVyX2Jsb2JfdCBpbnB1dCA9IHsgdG9fc2lnbiwgdG9fc2lnbl9zaXplIH07CisgICAgICAgIGtleW1hc3Rlcl9ibG9iX3QgaW5wdXQgPSB7dG9fc2lnbiwgdG9fc2lnbl9zaXplfTsKICAgICAgICAgc2l6ZV90IGlucHV0X2NvbnN1bWVkOwotICAgICAgICBlcnJvciA9IGtleW1hc3RlcjFfZGV2LT51cGRhdGUoa2V5bWFzdGVyMV9kZXYsIG9wX2hhbmRsZSwgTlVMTCAvKiBpbl9wYXJhbXMgKi8sCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmaW5wdXQsICZpbnB1dF9jb25zdW1lZCwgTlVMTCAvKiBvdXRfcGFyYW1zICovLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTlVMTCAvKiBvdXRwdXQgKi8pOworICAgICAgICBlcnJvciA9IGtleW1hc3RlcjFfZGV2LT51cGRhdGUoa2V5bWFzdGVyMV9kZXYsIG9wX2hhbmRsZSwgTlVMTCAvKiBpbl9wYXJhbXMgKi8sICZpbnB1dCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICZpbnB1dF9jb25zdW1lZCwgTlVMTCAvKiBvdXRfcGFyYW1zICovLCBOVUxMIC8qIG91dHB1dCAqLyk7CiAgICAgICAgIGlmIChlcnJvciAhPSBLTV9FUlJPUl9PSykgewogICAgICAgICAgICAgU0xPR0UoIkVycm9yIHNlbmRpbmcgZGF0YSB0byBrZXltYXN0ZXIgc2lnbmF0dXJlIHRyYW5zYWN0aW9uOiAlZCIsIGVycm9yKTsKICAgICAgICAgICAgIHJjID0gLTE7CkBAIC0zMzcsOCArMzE3LDcgQEAKIAogICAgICAgICBrZXltYXN0ZXJfYmxvYl90IHRtcF9zaWc7CiAgICAgICAgIGVycm9yID0ga2V5bWFzdGVyMV9kZXYtPmZpbmlzaChrZXltYXN0ZXIxX2Rldiwgb3BfaGFuZGxlLCBOVUxMIC8qIGluX3BhcmFtcyAqLywKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE5VTEwgLyogdmVyaWZ5IHNpZ25hdHVyZSAqLywgTlVMTCAvKiBvdXRfcGFyYW1zICovLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJnRtcF9zaWcpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTlVMTCAvKiB2ZXJpZnkgc2lnbmF0dXJlICovLCBOVUxMIC8qIG91dF9wYXJhbXMgKi8sICZ0bXBfc2lnKTsKICAgICAgICAgaWYgKGVycm9yICE9IEtNX0VSUk9SX09LKSB7CiAgICAgICAgICAgICBTTE9HRSgiRXJyb3IgZmluaXNoaW5nIGtleW1hc3RlciBzaWduYXR1cmUgdHJhbnNhY3Rpb246ICVkIiwgZXJyb3IpOwogICAgICAgICAgICAgcmMgPSAtMTsKQEAgLTM1MywxOSArMzMyLDE1IEBACiAgICAgICAgIGdvdG8gb3V0OwogICAgIH0KIAotICAgIG91dDoKLSAgICAgICAgaWYgKGtleW1hc3RlcjFfZGV2KQotICAgICAgICAgICAga2V5bWFzdGVyMV9jbG9zZShrZXltYXN0ZXIxX2Rldik7Ci0gICAgICAgIGlmIChrZXltYXN0ZXIwX2RldikKLSAgICAgICAgICAgIGtleW1hc3RlcjBfY2xvc2Uoa2V5bWFzdGVyMF9kZXYpOworb3V0OgorICAgIGlmIChrZXltYXN0ZXIxX2Rldikga2V5bWFzdGVyMV9jbG9zZShrZXltYXN0ZXIxX2Rldik7CisgICAgaWYgKGtleW1hc3RlcjBfZGV2KSBrZXltYXN0ZXIwX2Nsb3NlKGtleW1hc3RlcjBfZGV2KTsKIAotICAgICAgICByZXR1cm4gcmM7CisgICAgcmV0dXJuIHJjOwogfQogCi0KIC8qIFNob3VsZCB3ZSB1c2Uga2V5bWFzdGVyPyAqLwotc3RhdGljIGludCBrZXltYXN0ZXJfY2hlY2tfY29tcGF0aWJpbGl0eV9uZXcoKQoteworc3RhdGljIGludCBrZXltYXN0ZXJfY2hlY2tfY29tcGF0aWJpbGl0eV9uZXcoKSB7CiAgICAgcmV0dXJuIGtleW1hc3Rlcl9jb21wYXRpYmlsaXR5X2NyeXB0ZnNfc2NyeXB0KCk7CiB9CiAKQEAgLTM5NCwxMiArMzY5LDkgQEAKICNlbmRpZgogCiAvKiBUaGlzIHNpZ25zIHRoZSBnaXZlbiBvYmplY3QgdXNpbmcgdGhlIGtleW1hc3RlciBrZXkuICovCi1zdGF0aWMgaW50IGtleW1hc3Rlcl9zaWduX29iamVjdF9uZXcoc3RydWN0IGNyeXB0X21udF9mdHIgKmZ0ciwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHVuc2lnbmVkIGNoYXIgKm9iamVjdCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNpemVfdCBvYmplY3Rfc2l6ZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuc2lnbmVkIGNoYXIgKipzaWduYXR1cmUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplX3QgKnNpZ25hdHVyZV9zaXplKQoteworc3RhdGljIGludCBrZXltYXN0ZXJfc2lnbl9vYmplY3RfbmV3KHN0cnVjdCBjcnlwdF9tbnRfZnRyKiBmdHIsIGNvbnN0IHVuc2lnbmVkIGNoYXIqIG9iamVjdCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzaXplX3Qgb2JqZWN0X3NpemUsIHVuc2lnbmVkIGNoYXIqKiBzaWduYXR1cmUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90KiBzaWduYXR1cmVfc2l6ZSkgewogICAgIHVuc2lnbmVkIGNoYXIgdG9fc2lnbltSU0FfS0VZX1NJWkVfQllURVNdOwogICAgIHNpemVfdCB0b19zaWduX3NpemUgPSBzaXplb2YodG9fc2lnbik7CiAgICAgbWVtc2V0KHRvX3NpZ24sIDAsIFJTQV9LRVlfU0laRV9C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