KeyGuard / index.html
SeaWolf-AI's picture
Describe the 10 minute certificate cache
7f6fccf verified
Raw History Blame Contribute Delete
82.9 kB
<!doctype html>
<html lang="ko" data-theme="dark">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>KeyGuard</title>
<meta name="description" content="Check whether your server/device RSA public keys are 'weak keys' — 100% in your browser. / 서버·장비 공개키가 '불량 키'인지 브라우저 안에서 자가진단." />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Space+Grotesk:wght@500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<style>
:root{
--bg:#0a0b14; --bg2:#0d0f1c; --panel:rgba(255,255,255,.04); --panel-br:rgba(255,255,255,.09);
--ink:#eef1ff; --muted:#9aa3c7; --faint:#6a7196;
--accent:#7c6cff; --accent2:#22d3ee; --accent3:#f472b6;
--ok:#34d399; --warn:#fbbf24; --bad:#fb5a6a;
--mono:'JetBrains Mono',ui-monospace,monospace;
--grad:linear-gradient(120deg,#7c6cff,#22d3ee);
--radius:20px;
}
:root:not([data-theme="dark"]){
--bg:#f6f7fb; --bg2:#eef1f8; --panel:rgba(14,16,32,.03); --panel-br:rgba(14,16,32,.10);
--ink:#121634; --muted:#4d5680; --faint:#767ea6;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{font-family:Inter,system-ui,"Apple SD Gothic Neo","Noto Sans KR","Noto Sans SC",sans-serif;background:var(--bg);color:var(--ink);line-height:1.6;-webkit-font-smoothing:antialiased;overflow-x:hidden}
.bgfx{position:fixed;inset:0;z-index:-1;overflow:hidden}
.orb{position:absolute;border-radius:50%;filter:blur(90px);opacity:.5;animation:float 18s ease-in-out infinite}
.orb.a{width:520px;height:520px;background:#7c6cff;top:-160px;left:-120px}
.orb.b{width:460px;height:460px;background:#22d3ee;top:20%;right:-140px;animation-delay:-6s}
.orb.c{width:420px;height:420px;background:#f472b6;bottom:-160px;left:30%;animation-delay:-11s;opacity:.35}
@keyframes float{0%,100%{transform:translate(0,0) scale(1)}50%{transform:translate(0,-40px) scale(1.08)}}
.grid-ovl{position:absolute;inset:0;background-image:linear-gradient(var(--panel-br) 1px,transparent 1px),linear-gradient(90deg,var(--panel-br) 1px,transparent 1px);background-size:56px 56px;opacity:.25;mask-image:radial-gradient(circle at 50% 30%,#000,transparent 72%)}
.wrap{max-width:980px;margin:0 auto;padding:0 20px}
nav{display:flex;align-items:center;justify-content:space-between;padding:22px 0;gap:12px;flex-wrap:wrap}
.brand{display:flex;align-items:center;gap:11px;font-family:'Space Grotesk';font-weight:700;font-size:19px;letter-spacing:-.01em}
.logo{width:34px;height:34px;border-radius:10px;background:var(--grad);display:grid;place-items:center;box-shadow:0 8px 26px rgba(124,108,255,.45)}
.logo svg{width:19px;height:19px}
.navbtns{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.langsw{display:flex;border:1px solid var(--panel-br);border-radius:999px;overflow:hidden;background:var(--panel)}
.langsw button{border:none;background:transparent;color:var(--muted);font-size:12.5px;padding:7px 12px;cursor:pointer;font-family:inherit;transition:.15s}
.langsw button.on{background:var(--grad);color:#0a0b14;font-weight:700}
.chip{font-size:12.5px;color:var(--muted);border:1px solid var(--panel-br);padding:7px 13px;border-radius:999px;background:var(--panel);cursor:pointer;transition:.2s}
.chip:hover{color:var(--ink);border-color:var(--accent)}
header.hero{padding:34px 0 18px;text-align:center}
.tagpill{display:inline-flex;gap:8px;align-items:center;font-size:12.5px;color:var(--muted);border:1px solid var(--panel-br);background:var(--panel);padding:7px 15px;border-radius:999px;margin-bottom:20px}
.dot{width:7px;height:7px;border-radius:50%;background:var(--ok);box-shadow:0 0 0 4px rgba(52,211,153,.18)}
h1{font-family:'Space Grotesk';font-size:clamp(32px,5.6vw,54px);line-height:1.05;letter-spacing:-.03em;margin:0 0 16px;font-weight:700}
h1 .g{background:var(--grad);-webkit-background-clip:text;background-clip:text;color:transparent}
.lead{font-size:clamp(16px,2.3vw,18px);color:var(--muted);max-width:640px;margin:0 auto 10px}
.sub{font-size:14px;color:var(--faint);max-width:600px;margin:14px auto 0}
.card{background:var(--panel);border:1px solid var(--panel-br);border-radius:var(--radius);backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px)}
/* about */
.about{margin:26px 0 8px;padding:24px}
.about h2{margin:0 0 12px;font-family:'Space Grotesk';font-size:20px}
.about p{margin:0 0 10px;font-size:14.5px;color:var(--muted)}
.about .kparts{display:grid;grid-template-columns:repeat(2,1fr);gap:12px;margin-top:16px}
.kpart{padding:14px;border-radius:12px;border:1px solid var(--panel-br);background:rgba(124,108,255,.04)}
.kpart .h{font-weight:600;font-size:13.5px;margin-bottom:4px}
.kpart .d{font-size:12.5px;color:var(--faint)}
.checker{margin:26px 0 10px;padding:26px}
.checker h2{margin:0 0 4px;font-size:18px;font-family:'Space Grotesk'}
.checker p.hint{margin:0 0 16px;font-size:13.5px;color:var(--faint)}
textarea{width:100%;min-height:150px;resize:vertical;background:rgba(0,0,0,.22);border:1px solid var(--panel-br);border-radius:14px;color:var(--ink);font-family:var(--mono);font-size:12.5px;padding:15px;outline:none;transition:.2s}
:root:not([data-theme="dark"]) textarea{background:#fff}
textarea:focus{border-color:var(--accent);box-shadow:0 0 0 4px rgba(124,108,255,.15)}
.samplebar{margin:4px 0 16px;padding:14px 16px;border-radius:14px;border:1px dashed var(--panel-br);background:rgba(124,108,255,.05)}
.sbl{display:block;font-size:12.5px;color:var(--accent2);font-weight:700;margin-bottom:10px}
.schips{display:flex;gap:9px;flex-wrap:wrap}
.schip{display:inline-flex;flex-direction:column;align-items:flex-start;gap:2px;text-align:left;border:1px solid var(--panel-br);background:var(--panel);border-radius:12px;padding:10px 13px;cursor:pointer;transition:.18s;max-width:230px}
.schip:hover{transform:translateY(-2px);border-color:var(--accent);box-shadow:0 8px 22px rgba(124,108,255,.25)}
.schip .st{font-size:13px;font-weight:600;color:var(--ink)}
.schip .sd{font-size:11px;color:var(--faint);line-height:1.35}
.schip.mix{background:var(--grad);border:none}
.schip.mix .st{color:#0a0b14}.schip.mix .sd{color:rgba(10,11,20,.72)}
.row{display:flex;gap:12px;flex-wrap:wrap;align-items:center;margin-top:14px}
button.run{flex:1;min-width:200px;border:none;cursor:pointer;font-weight:700;font-size:15px;color:#0a0b14;background:var(--grad);padding:15px 20px;border-radius:14px;transition:.2s;box-shadow:0 10px 30px rgba(124,108,255,.35)}
button.run:hover{transform:translateY(-2px)}
.secbtn{border:1px solid var(--panel-br);background:var(--panel);color:var(--muted);padding:15px 18px;border-radius:14px;cursor:pointer;font-size:13.5px;transition:.2s}
.secbtn:hover{color:var(--ink);border-color:var(--accent2)}
label.ck{display:flex;gap:9px;align-items:flex-start;font-size:12.5px;color:var(--muted);margin-top:14px;cursor:pointer}
label.ck input{margin-top:3px;accent-color:var(--accent)}
#results{margin-top:18px;display:none}
.summary{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;margin-bottom:16px}
.stat{padding:16px;text-align:center;border-radius:16px}
.stat .n{font-family:'Space Grotesk';font-size:28px;font-weight:700;line-height:1}
.stat .l{font-size:11.5px;color:var(--faint);margin-top:6px}
.stat.ok .n{color:var(--ok)}.stat.warn .n{color:var(--warn)}.stat.bad .n{color:var(--bad)}.stat.tot .n{color:var(--ink)}
.res{display:flex;gap:13px;align-items:flex-start;padding:15px;border-radius:14px;margin-bottom:9px;border:1px solid var(--panel-br)}
.res .ic{flex-shrink:0;width:30px;height:30px;border-radius:9px;display:grid;place-items:center;font-size:15px}
.res.safe .ic{background:rgba(52,211,153,.15)}.res.weak .ic{background:rgba(251,191,36,.15)}.res.critical .ic{background:rgba(251,90,106,.15)}
.res .body{flex:1;min-width:0}
.res .tt{font-weight:600;font-size:14px}
.res .ds{font-size:12.5px;color:var(--muted);word-break:break-all}
.res .badge{font-size:10.5px;font-weight:700;padding:3px 9px;border-radius:999px;flex-shrink:0}
.res.safe .badge{background:rgba(52,211,153,.15);color:var(--ok)}
.res.weak .badge{background:rgba(251,191,36,.15);color:var(--warn)}
.res.critical .badge{background:rgba(251,90,106,.15);color:var(--bad)}
.shared{margin-top:14px;padding:15px;border-radius:14px;border:1px solid var(--bad);background:rgba(251,90,106,.07)}
.shared h3{margin:0 0 8px;font-size:13.5px;color:var(--bad)}
/* dramatic verdict */
.verdict{margin:0 0 18px;padding:22px 20px;border-radius:18px;text-align:center;position:relative;overflow:hidden}
.verdict.bad{border:1px solid var(--bad);background:radial-gradient(120% 140% at 50% 0,rgba(251,90,106,.22),rgba(251,90,106,.04))}
.verdict.safe{border:1px solid var(--ok);background:radial-gradient(120% 140% at 50% 0,rgba(52,211,153,.18),rgba(52,211,153,.03))}
.verdict .big{font-family:'Space Grotesk';font-size:clamp(26px,5vw,40px);font-weight:700;line-height:1.05;letter-spacing:-.02em}
.verdict.bad .big{color:var(--bad)}.verdict.safe .big{color:var(--ok)}
.verdict .sub2{font-size:13.5px;color:var(--muted);margin-top:6px}
.verdict.bad .lock{font-size:38px;display:inline-block;animation:shake 1.1s ease-in-out infinite}
@keyframes shake{0%,100%{transform:rotate(0) scale(1)}15%{transform:rotate(-9deg) scale(1.12)}30%{transform:rotate(7deg)}45%{transform:rotate(-5deg)}60%{transform:rotate(3deg) scale(1.08)}}
.verdict.bad::after{content:"";position:absolute;inset:0;background:linear-gradient(90deg,transparent,rgba(251,90,106,.10),transparent);animation:sweep 2.4s linear infinite}
@keyframes sweep{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}
.crack{margin-top:10px;padding:13px 15px;border-radius:12px;background:rgba(0,0,0,.28);border:1px solid var(--panel-br)}
:root:not([data-theme="dark"]) .crack{background:rgba(14,16,32,.05)}
.crack .cl{font-size:11px;color:var(--bad);font-weight:700;letter-spacing:.03em;margin-bottom:7px;display:flex;align-items:center;gap:7px}
.crack .eq{font-family:var(--mono);font-size:12px;line-height:1.7;color:var(--ink);word-break:break-all}
.crack .eq .op{color:var(--accent2);font-weight:700}
.crack .eq .p{color:var(--bad)}
.crack .st{display:flex;gap:14px;margin-top:9px;flex-wrap:wrap}
.crack .st span{font-size:11px;color:var(--faint)}
.crack .st b{color:var(--ok);font-family:'Space Grotesk'}
section.block{margin:52px 0}
.eyebrow{font-size:12px;letter-spacing:.14em;text-transform:uppercase;color:var(--accent2);font-weight:700;margin-bottom:12px}
.block h2{font-family:'Space Grotesk';font-size:clamp(23px,4vw,32px);letter-spacing:-.02em;margin:0 0 10px}
.cards3{display:grid;grid-template-columns:repeat(3,1fr);gap:14px;margin-top:22px}
.mini{padding:22px}
.mini .e{font-size:26px;margin-bottom:10px}
.mini h4{margin:0 0 6px;font-size:15px;font-family:'Space Grotesk'}
.mini p{margin:0;font-size:13.5px;color:var(--muted)}
.qa{padding:20px 22px;margin-bottom:11px}
.qa .q{font-weight:600;font-size:15px;margin-bottom:5px}
.qa .a{font-size:14px;color:var(--muted)}
.proof{display:flex;gap:16px;flex-wrap:wrap;margin-top:20px}
.pf{flex:1;min-width:150px;padding:20px;text-align:center}
.pf .n{font-family:'Space Grotesk';font-size:30px;font-weight:700;background:var(--grad);-webkit-background-clip:text;background-clip:text;color:transparent}
.pf .l{font-size:12.5px;color:var(--faint);margin-top:6px}
.note{font-size:12.5px;color:var(--faint);border-left:2px solid var(--accent);padding:4px 0 4px 14px;margin-top:16px}
.warnbox{padding:16px 18px;border-radius:14px;border:1px solid var(--warn);background:rgba(251,191,36,.06);font-size:13px;color:var(--muted);margin-top:16px}
footer{margin:56px 0 40px;padding-top:26px;border-top:1px solid var(--panel-br);font-size:12.5px;color:var(--faint);text-align:center}
/* tabs */
.p443{margin:8px 0 0;padding-left:20px;color:var(--muted);font-size:14px;line-height:1.7}
.p443 .w{color:var(--warn);font-weight:600}
a.secbtn{display:inline-block;text-decoration:none}
a.sl{font-size:13px;color:var(--accent2)}
.addrguide .hs{overflow-wrap:anywhere;font-family:var(--mono);font-size:11px}
.addrguide summary{cursor:pointer;font-size:13.5px;color:var(--muted)}
.addrguide p{font-size:13.5px;color:var(--muted);margin:10px 0}
.addrguide .gl{font-size:12px;color:var(--faint);margin:10px 0 4px}
textarea.cmd{min-height:0;font-size:12px;padding:10px 12px;word-break:break-all}
.addrguide .secbtn{padding:9px 14px;margin-top:6px}
#addrmsg{color:var(--ink);font-size:14px}
.addrin{flex:1;min-width:220px;background:rgba(0,0,0,.22);border:1px solid var(--panel-br);border-radius:14px;color:var(--ink);font-family:var(--mono);font-size:16px;padding:14px 15px;outline:none}
:root:not([data-theme="dark"]) .addrin{background:#fff}
.addrin:focus{border-color:var(--accent);box-shadow:0 0 0 4px rgba(124,108,255,.15)}
.addrrow{display:flex;gap:10px;flex-wrap:wrap;align-items:baseline;border-top:1px solid var(--panel-br);padding:10px 2px;font-size:13px;color:var(--muted);overflow-wrap:anywhere}
.addrrow b{color:var(--ink);font-family:var(--mono)}
.tabs{display:flex;flex-wrap:wrap;gap:8px;justify-content:center;margin:6px 0 2px}
.tabs button{border:1px solid var(--panel-br);background:var(--panel);color:var(--muted);font-family:inherit;font-size:14px;font-weight:600;padding:11px 20px;border-radius:12px;cursor:pointer;transition:.18s}
.tabs button.on{background:var(--grad);color:#0a0b14;border-color:transparent;box-shadow:0 8px 22px rgba(124,108,255,.3)}
/* leaderboard */
.lbmeta{margin:22px 0 16px;padding:18px 20px;display:flex;gap:22px;flex-wrap:wrap;align-items:center;justify-content:center}
.lbmeta .m{text-align:center}.lbmeta .m .n{font-family:'Space Grotesk';font-size:24px;font-weight:700}.lbmeta .m .l{font-size:11.5px;color:var(--faint)}
.lbmeta .m .n.v{color:var(--bad)}.lbmeta .m .n.c{color:var(--ok)}
.board{padding:8px 6px 6px;overflow-x:auto}
table.lb{width:100%;border-collapse:collapse;min-width:640px}
table.lb th{font-size:11px;letter-spacing:.04em;text-transform:uppercase;color:var(--faint);font-weight:700;text-align:left;padding:10px}
table.lb td{padding:12px 10px;border-top:1px solid var(--panel-br);vertical-align:middle}
table.lb tr.win td{background:linear-gradient(90deg,rgba(255,209,102,.10),transparent)}
.rank{font-family:'Space Grotesk';font-weight:700;font-size:16px;color:var(--faint);width:34px}
tr.win .rank{color:#ffd166}
.dname{font-weight:600;font-size:13.5px}.dname .me{font-size:10px;font-weight:700;color:#0a0b14;background:#ffd166;padding:2px 7px;border-radius:999px;margin-left:6px}
.bar{position:relative;height:22px;border-radius:7px;background:rgba(127,127,127,.12);overflow:hidden;min-width:110px}
.bar>span{position:absolute;left:0;top:0;bottom:0;border-radius:7px;background:var(--grad)}
.bar>b{position:absolute;right:8px;line-height:22px;font-size:12px;font-weight:700;color:var(--ink)}
.fpr.z{color:var(--ok);font-family:var(--mono);font-size:12.5px}.fpr.n{color:var(--bad);font-family:var(--mono);font-size:12.5px}
.cats{display:flex;gap:4px}.cc{width:30px;height:24px;border-radius:6px;display:grid;place-items:center;font-size:10px;font-weight:700;font-family:var(--mono)}
.foot-notes{font-size:12px;color:var(--faint);margin-top:12px}.foot-notes li{margin-bottom:5px}
@media(max-width:720px){.summary{grid-template-columns:repeat(2,1fr)}.cards3{grid-template-columns:1fr}.about .kparts{grid-template-columns:1fr}.schip{max-width:none;flex:1 1 140px}}
</style>
</head>
<body>
<div class="bgfx"><div class="orb a"></div><div class="orb b"></div><div class="orb c"></div><div class="grid-ovl"></div></div>
<div class="wrap">
<nav>
<div class="brand">
<span class="logo"><svg viewBox="0 0 24 24" fill="none"><path d="M12 2l7 3v6c0 4.5-3 8.2-7 9-4-0.8-7-4.5-7-9V5l7-3z" stroke="#0a0b14" stroke-width="2" stroke-linejoin="round"/><path d="M9 12l2 2 4-4" stroke="#0a0b14" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></span>
KeyGuard
</div>
<div class="navbtns">
<div class="langsw" id="langsw">
<button data-lang="ko">한국어</button><button data-lang="en">EN</button><button data-lang="zh">中文</button>
</div>
<span class="chip" id="themeToggle">◐</span>
</div>
</nav>
<header class="hero">
<div class="tagpill"><span class="dot"></span> <span data-i18n="tag"></span></div>
<h1><span data-i18n="h1a"></span><br><span class="g" data-i18n="h1b"></span></h1>
<p class="lead" data-i18n="lead"></p>
<p class="sub" data-i18n="sub"></p>
</header>
<div class="tabs"><button id="tabCheck" class="on" data-i18n="tab_check"></button><button id="tabAddr" data-i18n="tab_addr"></button><button id="tabBench" data-i18n="tab_bench"></button></div>
<div id="tab-check">
<!-- ABOUT / 설명 -->
<div class="card about">
<h2 data-i18n="about_h"></h2>
<p data-i18n="about_p1"></p>
<p data-i18n="about_p2"></p>
<div class="kparts">
<div class="kpart"><div class="h" data-i18n="about_k1h"></div><div class="d" data-i18n="about_k1d"></div></div>
<div class="kpart"><div class="h" data-i18n="about_k2h"></div><div class="d" data-i18n="about_k2d"></div></div>
<div class="kpart"><div class="h" data-i18n="about_k3h"></div><div class="d" data-i18n="about_k3d"></div></div>
<div class="kpart"><div class="h" data-i18n="about_k4h"></div><div class="d" data-i18n="about_k4d"></div></div>
</div>
</div>
<!-- CHECKER -->
<div class="card checker" id="checker">
<h2 data-i18n="chk_h"></h2>
<p class="hint" data-i18n="chk_hint"></p>
<div class="samplebar">
<span class="sbl" data-i18n="chk_sample"></span>
<div class="schips" id="schips"></div>
</div>
<textarea id="keyin" data-i18n-ph="chk_ph"></textarea>
<label class="ck"><input type="checkbox" id="consent"><span data-i18n="chk_consent"></span></label>
<div class="row">
<button class="run" id="runbtn" data-i18n="chk_run"></button>
<button class="secbtn" id="filebtn" data-i18n="lc_file"></button><input type="file" id="filein" accept=".txt,.pem,.crt,.cer,.pub,text/plain" multiple style="display:none"><button class="secbtn" id="clearbtn" data-i18n="chk_clear"></button>
</div>
<div id="results"><div id="verdict"></div><div class="summary" id="summary"></div><div id="reslist"></div><div id="sharedbox"></div></div>
</div>
<p class="note" data-i18n="chk_note"></p>
<section class="block">
<div class="eyebrow" data-i18n="how_eye"></div>
<h2 data-i18n="how_h"></h2>
<div class="cards3">
<div class="card mini"><div class="e">📋</div><h4 data-i18n="how1h"></h4><p data-i18n="how1d"></p></div>
<div class="card mini"><div class="e">⚡</div><h4 data-i18n="how2h"></h4><p data-i18n="how2d"></p></div>
<div class="card mini"><div class="e">🛡️</div><h4 data-i18n="how3h"></h4><p data-i18n="how3d"></p></div>
</div>
</section>
<section class="block">
<div class="eyebrow" data-i18n="what_eye"></div>
<h2 data-i18n="what_h"></h2>
<div class="cards3">
<div class="card mini"><div class="e">📏</div><h4 data-i18n="w1h"></h4><p data-i18n="w1d"></p></div>
<div class="card mini"><div class="e">🤏</div><h4 data-i18n="w2h"></h4><p data-i18n="w2d"></p></div>
<div class="card mini"><div class="e">🔗</div><h4 data-i18n="w3h"></h4><p data-i18n="w3d"></p></div>
<div class="card mini"><div class="e">🧬</div><h4 data-i18n="w4h"></h4><p data-i18n="w4d"></p></div>
</div>
</section>
<section class="block">
<div class="eyebrow" data-i18n="proof_eye"></div>
<h2 data-i18n="proof_h"></h2>
<p class="lead" style="margin-left:0;text-align:left" data-i18n="proof_lead"></p>
<div class="proof">
<div class="card pf"><div class="n">10/10</div><div class="l" data-i18n="proof_s1"></div></div>
<div class="card pf"><div class="n">1M+</div><div class="l" data-i18n="proof_s2"></div></div>
<div class="card pf"><div class="n">0</div><div class="l" data-i18n="proof_s3"></div></div>
</div>
<div class="note" data-i18n="proof_note"></div>
</section>
<section class="block">
<div class="eyebrow" data-i18n="faq_eye"></div>
<h2 data-i18n="faq_h"></h2>
<div class="card qa"><div class="q" data-i18n="faq1q"></div><div class="a" data-i18n="faq1a"></div></div>
<div class="card qa"><div class="q" data-i18n="faq2q"></div><div class="a" data-i18n="faq2a"></div></div>
<div class="card qa"><div class="q" data-i18n="faq3q"></div><div class="a" data-i18n="faq3a"></div></div>
<div class="card qa"><div class="q" data-i18n="faq4q"></div><div class="a" data-i18n="faq4a"></div></div>
<div class="warnbox" data-i18n="faq_warn"></div>
</section>
</div><!-- /tab-check -->
<div id="tab-addr" style="display:none">
<div class="card checker" id="addrcard" style="margin-top:26px">
<h2 data-i18n="ad_h"></h2>
<p class="hint" data-i18n="ad_hint"></p>
<div class="row" style="margin-top:0"><input id="addrin" class="addrin" type="text" inputmode="url" autocapitalize="off" autocomplete="off" spellcheck="false" maxlength="260" data-i18n-ph="ad_ph"><button class="secbtn" id="myipbtn" data-i18n="ad_my"></button></div>
<label class="ck"><input type="checkbox" id="consent2"><span data-i18n="ad_consent"></span></label>
<div class="row"><button class="run" id="addrbtn" data-i18n="ad_run"></button><button class="secbtn" id="addrclear" data-i18n="ad_clear"></button></div>
<div id="addrmsg" class="note" role="status" aria-live="polite" style="display:none"></div>
<div id="addrlist"></div>
<div id="addrres"></div>
</div>
<p class="note" data-i18n="ad_more"></p>
<div class="card checker" id="card443" style="margin-top:18px">
<h2 data-i18n="lc_ph_h"></h2>
<ul class="p443"><li data-i18n="lc_p1"></li><li data-i18n="lc_p2"></li><li data-i18n="lc_p3"></li><li class="w" data-i18n="lc_p4"></li></ul>
</div>
<div class="card checker addrguide" id="guide" style="margin-top:18px">
<h2 data-i18n="lc_lh"></h2>
<p>1. <span data-i18n="lc_l1"></span></p>
<div class="row"><a class="secbtn dl" href="local/keyguard-local-v2.ps1" download="keyguard-local-v2.ps1" data-i18n="lc_lw"></a><a class="sl" href="https://huggingface.co/spaces/FINAL-Bench/KeyGuard/blob/main/local/keyguard-local-v2.ps1" target="_blank" rel="noopener" data-i18n="lc_src"></a></div>
<div class="gl"><span data-i18n="lc_run"></span> · PowerShell</div><textarea id="runwin" class="cmd" readonly rows="2">powershell -ExecutionPolicy Bypass -File "$HOME\Downloads\keyguard-local-v2.ps1"</textarea><button class="secbtn cp" data-for="runwin" data-i18n="gd_copy"></button>
<div class="gl hs">SHA-256 5efac92df5f2ecfd887a495e4475e44060c5bad229d0d8bc8b8d08092be1e8a0</div>
<div class="row"><a class="secbtn dl" href="local/keyguard-local-v2.py" download="keyguard-local-v2.py" data-i18n="lc_lp"></a><a class="sl" href="https://huggingface.co/spaces/FINAL-Bench/KeyGuard/blob/main/local/keyguard-local-v2.py" target="_blank" rel="noopener" data-i18n="lc_src"></a></div>
<div class="gl"><span data-i18n="lc_run"></span> · Terminal</div><textarea id="runnix" class="cmd" readonly rows="2">python3 ~/Downloads/keyguard-local-v2.py</textarea><button class="secbtn cp" data-for="runnix" data-i18n="gd_copy"></button>
<div class="gl hs">SHA-256 1d79cea414535dea8c8ba7e020e020c9e3bb5407d842d885c1d6746c3b349152</div>
<p>2. <span data-i18n="lc_l2"></span></p>
<button class="secbtn" id="gogo" data-i18n="gd_go"></button>
<details style="margin-top:16px"><summary data-i18n="lc_one"></summary>
<p data-i18n="gd_s1"></p><div class="gl">Windows PowerShell</div><textarea id="cmdwin" class="cmd" readonly rows="5"></textarea><button class="secbtn cp" data-for="cmdwin" data-i18n="gd_copy"></button><div class="gl">macOS · Linux</div><textarea id="cmdnix" class="cmd" readonly rows="2"></textarea><button class="secbtn cp" data-for="cmdnix" data-i18n="gd_copy"></button></details>
<p class="note" data-i18n="lc_auth"></p>
</div>
</div><!-- /tab-addr -->
<div id="tab-bench" style="display:none">
<section class="block" style="margin-top:26px">
<div class="eyebrow" data-i18n="lb_eye"></div>
<h2 class="block" style="font-family:'Space Grotesk';font-size:clamp(23px,4vw,32px);margin:0 0 8px" data-i18n="lb_h"></h2>
<p class="lead" style="margin-left:0;text-align:left" data-i18n="lb_lead"></p>
<div class="card lbmeta" id="lbmeta"></div>
<div class="card board"><table class="lb"><thead><tr><th>#</th><th data-i18n="th_det"></th><th data-i18n="th_recall"></th><th data-i18n="th_fpr"></th><th data-i18n="th_time"></th><th data-i18n="th_cat"></th></tr></thead><tbody id="lbrows"></tbody></table></div>
<p class="note" data-i18n="lb_read"></p>
<div class="eyebrow" style="margin-top:28px" data-i18n="lb_method_eye"></div>
<div class="cards3">
<div class="card mini"><div class="e">🧪</div><h4 data-i18n="lb_m1h"></h4><p data-i18n="lb_m1d"></p></div>
<div class="card mini"><div class="e">⚖️</div><h4 data-i18n="lb_m2h"></h4><p data-i18n="lb_m2d"></p></div>
<div class="card mini"><div class="e">🔁</div><h4 data-i18n="lb_m3h"></h4><p data-i18n="lb_m3d"></p></div>
</div>
<ul class="foot-notes" id="lbnotes"></ul>
</section>
</div><!-- /tab-bench -->
<footer><span data-i18n="foot1"></span><br><span data-i18n="foot2"></span></footer>
</div>
<script src="samples.js"></script>
<script src="bench.js"></script>
<script>
/* ================= i18n ================= */
const I18N={
ko:{
tag:"붙여넣은 키는 100% 브라우저 안에서 검사 · 서버로 전송되지 않습니다",
h1a:"내 장비 암호키,", h1b:"혹시 불량품 아닐까?",
lead:"공장에서 실수로 여러 장비에 똑같은 비밀 소수를 넣어 출고하면, 누군가 그걸 찾는 순간 그 장비들은 전부 열립니다. KeyGuard는 당신의 공개키가 그런 불량 키인지 수학으로 30초 만에 검사합니다.",
sub:"개인키 말고 공개키만 넣으세요. 공개키는 원래 공개되는 정보라 안전합니다.",
about_h:"이게 무엇인가요?",
about_p1:"RSA 암호키는 '큰 소수 두 개를 곱한 자물쇠'입니다. 두 소수를 알아내면 자물쇠가 열리는데, 보통은 알아낼 방법이 없어 안전합니다. 문제는 난수(무작위)가 빈약한 싸구려 장비들이 부팅 직후 키를 만들 때 생깁니다.",
about_p2:"이때 서로 다른 기기가 우연히 같은 소수를 쓰거나, 두 소수가 너무 가깝게 뽑히면, 공개키만으로 개인키를 되찾을 수 있습니다. KeyGuard는 바로 이런 '구조적 결함 키'를 찾아냅니다 — 암호가 약해서가 아니라, 일부 구현이 엉망이라서 생기는 문제입니다.",
about_k1h:"🔗 소수 공유 (batch-GCD)", about_k1d:"여러 장비가 같은 소수 사용 → 최대공약수 한 번에 양쪽 개인키 복원",
about_k2h:"🤏 가까운 소수 (Fermat)", about_k2d:"두 소수가 너무 가까우면 2048비트라도 즉시 분해",
about_k3h:"🧬 ROCA (CVE-2017-15361)", about_k3d:"특정 결함칩이 만든 취약 패턴 키 의심 탐지",
about_k4h:"📏 짧은/약한 키", about_k4d:"768비트 이하(분해 가능)·2048 미만(교체 권장)·비정상 지수",
chk_h:"🔎 공개키 자가진단",
chk_hint:"RSA 공개키를 한 줄에 하나씩 넣으세요. 형식: PEM(-----BEGIN PUBLIC KEY-----), 16진수 모듈러스, 10진수 N, 또는 N:e. 여러 장비 키를 함께 넣으면 서로 소수를 공유하는지도 검사합니다.",
chk_sample:"⚡ 입력이 귀찮다면? 샘플 유형을 눌러 바로 결과를 보세요",
chk_ph:"예)\n-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqh...\n-----END PUBLIC KEY-----\n\n또는 16진수 모듈러스:\nC897A647627FAEBB...\n\n또는 N:e 형식:\n2533...9077 : 65537",
chk_consent:"검사하려는 공개키는 내가 소유했거나 점검 위임을 받은 장비의 것입니다. 타인의 장비·키를 무단으로 검사하지 않습니다.",
chk_run:"자가진단 실행", chk_clear:"지우기",
chk_note:"모든 검사는 당신의 브라우저 안에서만 실행됩니다. 어떤 키도 서버로 저장·전송되지 않으며('지우기'로 입력을 즉시 비울 수 있음), 뚫리는 키라도 복원된 개인키 값은 절대 표시하지 않고 '복원 가능' 사실만 알려줍니다.",
how_eye:"어떻게 쓰나요", how_h:"3단계면 끝",
how1h:"1. 공개키 붙여넣기", how1d:"서버·공유기·IoT 장비의 공개키(인증서/SSH 공개키)를 넣습니다. 개인키는 넣지 마세요.",
how2h:"2. 실행", how2d:"브라우저가 즉시 수학 검사를 돌립니다. 인터넷 전송 없음 — 전부 당신 기기 안에서.",
how3h:"3. 결과 확인", how3d:"안전/주의/위험으로 한눈에. 위험이면 왜 위험한지 알려줍니다.",
what_eye:"무엇을 검사하나", what_h:"4가지 치명적 결함",
w1h:"너무 짧은 키", w1d:"768비트 이하는 오늘날 분해 가능, 2048 미만은 교체 권장.",
w2h:"가까운 소수 (Fermat)", w2d:"두 소수가 너무 가까우면 2048비트라도 즉시 뚫립니다.",
w3h:"소수 공유 (batch-GCD)", w3d:"여러 장비가 같은 소수를 쓰면 최대공약수 한 번에 둘 다 열립니다.",
w4h:"ROCA 결함칩", w4d:"특정 칩(CVE-2017-15361)이 만든 취약 패턴 키를 의심 탐지합니다.",
proof_eye:"검증됨", proof_h:"실제 대규모 공개키로 검증 완료",
proof_lead:"합성 취약 키를 정확히 탐지하고, 실제 인증서 투명성(CT) 로그의 공개키 100만 개를 12분에 처리해 대규모 동작을 확인했습니다.",
proof_s1:"심은 취약 키 탐지 정확도 (오탐 0)", proof_s2:"실제 CT 공개키 분석 (스파크)", proof_s3:"붙여넣은 키의 서버 전송 (전부 클라이언트)",
proof_note:"참고: 공개 CT 로그의 웹 인증서는 대체로 잘 생성되어 취약 키가 드뭅니다. 취약 키는 주로 임베디드·IoT의 자가서명 인증서에 분포 — 그래서 '내 장비를 직접 검사'하는 이 도구가 의미가 있습니다.",
faq_eye:"자주 묻는 질문", faq_h:"궁금한 것들",
faq1q:"제 개인키가 유출되나요?", faq1a:"아니요. 공개키만 넣고, 그마저도 브라우저 밖으로 나가지 않습니다.",
faq2q:"왜 공개키만으로 뚫리는 걸 알 수 있죠?", faq2a:"공개키에는 두 소수의 '곱'이 들어 있습니다. 소수가 가깝거나 공유되면 그 곱만으로 소수를 되찾을 수 있습니다.",
faq3q:"여러 장비를 한꺼번에 넣어도 되나요?", faq3a:"네, 권장합니다. 장비들끼리 소수를 공유하는지는 여러 키를 함께 넣어야 검사됩니다.",
faq4q:"안전으로 나오면 100% 안심인가요?", faq4a:"이 도구가 검사하는 4가지 결함이 없다는 뜻입니다. 암호의 다른 측면은 별도 점검이 필요합니다.",
faq_warn:"⚠️ 이 도구는 본인 소유 또는 점검 위임을 받은 장비의 공개키에만 사용하세요. 타인의 장비·시스템을 무단으로 검사·침투하는 것은 법으로 금지되어 있습니다.",
foot1:"KeyGuard · 공개키 자가진단 · 붙여넣기 검사는 브라우저 안에서만 실행됩니다",
foot2:"교육 및 본인 자산 점검용 · 책임 있는 보안 점검(Responsible Disclosure) 원칙 준수",
b_safe:"안전", b_weak:"주의", b_bad:"위험",
s_tot:"검사한 키", s_safe:"안전", s_warn:"주의", s_bad:"위험",
f_nodefect:"알려진 결함 없음",
f_size_c:(b)=>`키 길이 ${b}비트 — 현재 분해 가능 범위`,
f_size_w:(b)=>`키 길이 ${b}비트 — 2048 미만, 교체 권장`,
f_exp:(e)=>`공개지수 e=${e} 비정상`,
f_fermat:(it)=>`가까운 소수(Fermat) — 개인키 복원 가능 (반복 ${it}회)`,
f_roca:"ROCA 지문 의심 — 정밀검사 필요 (CVE-2017-15361)",
f_shared:(w)=>`🔗 소수 공유 (${w}) — 개인키 복원 가능`,
key_n:(i,b)=>`키 #${i} · ${b}bit`,
shared_title:"🔗 소수 공유 발견 — 아래 키들은 서로의 개인키를 복원할 수 있습니다",
shared_row:(a,b,bits)=>`${bits}비트 소수 공유 — 양쪽 모두 복원 가능 (개인키 값은 표시하지 않음)`,
shared_pair:(a,b)=>`키 #${a} ↔ 키 #${b}`,
noshare_t:"소수 공유 없음", noshare_d:(n)=>`입력한 ${n}개 키는 서로 소수를 공유하지 않습니다 (batch-GCD 검사 완료).`,
single_t:"소수 공유 검사는 2개 이상 키가 필요합니다", single_d:"여러 장비의 공개키를 함께 넣으면 서로 소수를 공유하는지 검사합니다.",
al_consent:"본인 소유/위임 장비 확인에 체크해 주세요.", al_nokey:"유효한 RSA 공개키를 찾지 못했습니다. 형식을 확인해 주세요.",
busy:"검사 중…",
cr_label:"복원된 소인수 (이 키는 이미 깨진 키)", cr_time:"복원 시간", cr_iter:"Fermat 반복", cr_via:"복원 경로", cr_note:"공개 모듈러스만으로 누구나 복원 가능 → 즉시 폐기 필요",
vd_bad:(n)=>`위험한 키 ${n}개`, vd_bad_sub:"길이 또는 지수가 위험합니다. 키를 교체하세요.", vd_cracked:(n)=>`${n}개 키 뚫림 — CRACKED`, vd_cracked_sub:"개인키가 복원됐습니다. 해당 키는 즉시 폐기·교체하세요.",
vd_weak:(n)=>`${n}개 키 주의 필요`, vd_weak_sub:"지금 당장 뚫리진 않지만 교체를 권장합니다.",
vd_safe:"모두 안전", vd_safe_sub:"이 도구가 검사하는 4대 결함이 없습니다.",
tab_check:"🔎 자가진단", tab_bench:"🏆 벤치마크", tab_addr:"🌐 주소로 점검", lc_ph_h:"🚪 443 포트 안내", lc_p1:"443은 HTTPS(보안 웹 접속)가 드나드는 문입니다. 이 점검은 인터넷 쪽에서 그 문이 열린 기기만 볼 수 있습니다.", lc_p2:"집·사무실 공유기나 통신사는 보통 이 문을 닫아 둡니다. 그래서 「내 IP」는 응답 없음이 흔하며, 고장이 아닙니다.", lc_p3:"응답 없음은 열쇠를 보지 못했다는 뜻이고 안전 판정이 아닙니다. 안쪽 기기는 아래 방법으로 점검하십시오.", lc_p4:"점검하려고 공유기의 443 포트를 일부러 열지 마십시오. 닫혀 있는 편이 안전합니다.", lc_lh:"🏠 내 네트워크 점검기 (집·회사 안의 기기)", lc_l1:"스크립트를 내려받아 실행합니다. 내 PC가 속한 사설 네트워크에서 공개키만 읽어 안전·주의·위험을 바로 보여 줍니다. 질문이 나오면 YES를 입력하십시오. 로그인 시도와 인터넷 전송은 없습니다.", lc_l2:"(선택) 같은 폴더에 생기는 keyguard_keys.txt 를 자가진단 탭의 「파일 열기」로 넣으면 브라우저 화면에서도 자세히 볼 수 있습니다.", lc_lw:"내려받기: Windows", lc_lp:"내려받기: macOS · Linux (Python 3)", lc_src:"코드 보기", lc_run:"실행", lc_one:"기기 한 대만 빠르게", lc_auth:"본인 소유이거나 점검 권한이 있는 네트워크에서만 사용하십시오.", lc_file:"📂 파일 열기", gd_h:"🏠 집·회사 안의 기기는 이렇게 점검합니다", gd_s1:"같은 네트워크의 PC에서 아래 명령을 실행합니다. 주소는 점검할 기기(공유기, CCTV, 프린터)로 바꾸십시오.", gd_s2:"출력된 인증서를 자가진단 탭에 붙여넣습니다. 여러 기기를 함께 넣으면 서로 비교합니다. 붙여넣은 내용은 브라우저 밖으로 나가지 않습니다.", gd_copy:"복사", gd_copied:"복사됨", gd_go:"자가진단 탭으로", ad_h:"🌐 도메인·IP로 점검", ad_hint:"점검 서버가 입력한 주소의 443 포트(HTTPS)에만 접속해 공개 인증서를 받아 옵니다. 판정은 이 브라우저에서 합니다. 기록은 남기지 않으며, 공개 인증서만 10분 동안 메모리에 둡니다.", ad_ph:"예) example.com 또는 203.0.113.10", ad_my:"📍 내 IP 넣기", ad_consent:"이 주소의 기기는 내가 소유했거나 점검 위임을 받은 기기입니다. 타인의 기기를 무단으로 점검하지 않습니다.", ad_run:"주소 점검", ad_clear:"목록 비우기", ad_more:"기기를 하나씩 더 점검하면 목록에 쌓이고, 같은 소수를 쓰는지 서로 비교합니다. 사설 IP(192.168.x.x 등)는 인터넷에서 닿지 않으므로 자가진단 탭에 인증서를 붙여넣으십시오.", ad_self:"자체 서명", ad_exp:"만료", ad_issuer:"발급", ad_got:"내 접속 IP를 넣었습니다. 위임 확인에 체크하고 점검을 누르십시오.", ad_ec:"타원곡선 키를 쓰는 기기입니다. RSA 점검 대상이 아닙니다.", ad_other:"RSA 키가 아닙니다. 점검 대상이 아닙니다.", ad_noaddr:"주소를 입력해 주세요.", ad_err:{"bad_target": "주소 형식을 확인해 주세요. 도메인이나 IP 하나만 넣을 수 있고 포트와 경로는 받지 않습니다.", "private_target": "내부 주소는 인터넷에서 닿지 않습니다. 아래 방법으로 이 PC에서 점검하십시오.", "dns": "주소를 찾지 못했습니다.", "connect": "443 포트가 닫혀 있습니다. 인터넷 쪽에서 이 기기의 열쇠를 볼 수 없다는 뜻이며 안전 판정은 아닙니다.", "timeout": "밖에서 보이지 않는 기기입니다(443 응답 없음). 고장이 아니며, 인터넷 쪽에서 이 기기의 열쇠를 볼 수 없다는 뜻입니다. 안전 판정은 아닙니다.", "tls": "TLS 연결을 맺지 못했습니다.", "rate": "요청이 많습니다. 잠시 뒤 다시 해 주세요.", "consent": "위임 확인에 체크해 주세요.", "server": "점검 서버를 깨우는 중입니다. 1분쯤 뒤에 다시 눌러 주세요.", "nomyip": "접속 IP를 확인하지 못했습니다."},
lb_eye:"스파크 실측 · 조작 없음", lb_h:"취약키 탐지 벤치마크",
lb_lead:"표준 취약키 테스트셋에서 탐지 방법들의 재현율·오탐률·속도를 실측해 순위. 단일 방법은 일부만, 결합한 KeyGuard는 전 유형을 잡습니다.",
th_det:"탐지기", th_recall:"재현율", th_fpr:"오탐", th_time:"시간", th_cat:"유형별",
lb_read:"재현율=실제 취약키 중 적발 %, 오탐=멀쩡한 키 오지목 %. 고전 분해(Trial·Pollard)는 2048비트에 0% — 탐지는 분해가 아니라 구조적 결함 찾기이기 때문.",
lb_method_eye:"방법론 (145키 · 시드 고정 · 재현가능)",
lb_m1h:"음성 80 / 양성 65", lb_m1d:"정상 2048키 80 + 취약 65(가까운소수·공유·짧은키·지수)",
lb_m2h:"동일 조건", lb_m2d:"모든 탐지기가 같은 145키를 같은 기계(스파크)에서 처리",
lb_m3h:"재현 가능", lb_m3d:"고정 시드(20262025) — 언제든 동일 재현, 조작 불가",
lb_notes:["ROCA는 본 셋에 합성 양성이 없어 0%(완전성 위해 포함).","고전 분해는 2048비트 불가로 0%(반복 상한 내 측정).","소규모 자체셋 — 숫자는 측정값만, 과장 없음."],
catlabel:{close:"가까운소수",shared:"소수공유",short:"짧은키",bade:"지수"}, me_tag:"우리",
sample:{fermat:["🤏 가까운 소수","두 소수가 너무 가까운 2048비트 키 — Fermat로 즉시 분해"],shared:["🔗 소수 공유 (2대)","두 장비가 같은 소수 사용 — batch-GCD로 양쪽 다 뚫림"],short:["📏 너무 짧은 키","512비트 — 현재 분해 가능 범위"],bade:["⚠️ 비정상 지수","공개지수 e=2 (잘못된 설정)"],safe:["✓ 정상 키","잘 생성된 2048비트 실제 인증서 키 — 안전"],mix:["🎯 전부 섞기","위 모든 유형을 한 번에 — 종합 리포트"]}
},
en:{
tag:"Pasted keys are checked 100% in your browser · never sent to a server",
h1a:"Your device's crypto key —", h1b:"is it a factory defect?",
lead:"If a factory mistakenly ships many devices with the same secret prime, anyone who finds it can open them all. KeyGuard checks, with math in 30 seconds, whether your public key is one of those defective keys.",
sub:"Paste the PUBLIC key only, never the private key. Public keys are meant to be public, so this is safe.",
about_h:"What is this?",
about_p1:"An RSA key is a 'lock made by multiplying two large primes'. Knowing the two primes opens the lock — normally there's no way to find them, so it's safe. The problem starts when cheap devices with weak randomness generate keys right after boot.",
about_p2:"When two different devices happen to use the same prime, or the two primes are picked too close together, the private key can be recovered from the public key alone. KeyGuard finds exactly these 'structurally defective keys' — not because the cipher is weak, but because some implementations are broken.",
about_k1h:"🔗 Shared prime (batch-GCD)", about_k1d:"Devices reuse a prime → one GCD recovers both private keys",
about_k2h:"🤏 Close primes (Fermat)", about_k2d:"If the two primes are too close, even 2048-bit factors instantly",
about_k3h:"🧬 ROCA (CVE-2017-15361)", about_k3d:"Detects the vulnerable key pattern from certain faulty chips",
about_k4h:"📏 Short/weak keys", about_k4d:"≤768-bit (factorable), <2048 (replace), bad exponent",
chk_h:"🔎 Public-key self-check",
chk_hint:"Paste one RSA public key per line. Formats: PEM (-----BEGIN PUBLIC KEY-----), hex modulus, decimal N, or N:e. Paste keys from several devices together to also check for shared primes.",
chk_sample:"⚡ Don't want to type? Click a sample type to see results instantly",
chk_ph:"e.g.)\n-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqh...\n-----END PUBLIC KEY-----\n\nor a hex modulus:\nC897A647627FAEBB...\n\nor N:e form:\n2533...9077 : 65537",
chk_consent:"The public keys I'm checking belong to devices I own or am authorized to test. I will not test anyone else's devices or keys without permission.",
chk_run:"Run self-check", chk_clear:"Clear",
chk_note:"All checks run entirely inside your browser. No key is stored or sent to any server (use 'Clear' to wipe the input immediately). Even for a breakable key, the recovered private key is never shown — only the fact that it is recoverable.",
how_eye:"How to use", how_h:"Three simple steps",
how1h:"1. Paste public keys", how1d:"Paste the public keys (certificates / SSH public keys) of your servers, routers, IoT devices. Never paste private keys.",
how2h:"2. Run", how2d:"Your browser runs the math checks instantly. No network — all on your device.",
how3h:"3. See results", how3d:"Safe / Caution / Danger at a glance. If dangerous, it tells you why.",
what_eye:"What it checks", what_h:"Four fatal defects",
w1h:"Keys too short", w1d:"≤768-bit is factorable today; <2048 should be replaced.",
w2h:"Close primes (Fermat)", w2d:"If the two primes are too close, even a 2048-bit key breaks instantly.",
w3h:"Shared primes (batch-GCD)", w3d:"If devices share a prime, one GCD opens both.",
w4h:"ROCA faulty chips", w4d:"Detects vulnerable keys from certain chips (CVE-2017-15361).",
proof_eye:"Verified", proof_h:"Validated on real large-scale public keys",
proof_lead:"Detects planted weak keys exactly, and verified at scale on 1,000,000+ real public keys from Certificate Transparency (CT) logs in 12 minutes.",
proof_s1:"Detection accuracy on planted weak keys (0 false positives)", proof_s2:"Real CT public keys analyzed (on Spark)", proof_s3:"Pasted keys sent to a server (all client-side)",
proof_note:"Note: Web certificates in public CT logs are usually well-generated, so weak keys are rare there. Weak keys mostly live in self-signed certs of embedded/IoT devices — which is why checking YOUR OWN devices with this tool matters.",
faq_eye:"FAQ", faq_h:"Common questions",
faq1q:"Will my private key leak?", faq1a:"No. You paste only the public key, and even that never leaves your browser.",
faq2q:"How can a public key alone reveal a break?", faq2a:"A public key contains the 'product' of two primes. If primes are close or shared, that product alone lets us recover them.",
faq3q:"Can I paste many devices at once?", faq3a:"Yes, recommended. Shared-prime checks require several keys pasted together.",
faq4q:"If it says Safe, am I 100% safe?", faq4a:"It means the four defects this tool checks are absent. Other aspects of your crypto need separate review.",
faq_warn:"⚠️ Use this tool only on public keys of devices you own or are authorized to test. Testing or intruding on others' systems without permission is illegal.",
foot1:"KeyGuard · public-key self-check · pasted keys are checked only inside your browser",
foot2:"For education and checking your own assets · follows Responsible Disclosure",
b_safe:"Safe", b_weak:"Caution", b_bad:"Danger",
s_tot:"Keys checked", s_safe:"Safe", s_warn:"Caution", s_bad:"Danger",
f_nodefect:"No known defect",
f_size_c:(b)=>`Key length ${b}-bit — within factorable range`,
f_size_w:(b)=>`Key length ${b}-bit — under 2048, replace recommended`,
f_exp:(e)=>`Public exponent e=${e} is abnormal`,
f_fermat:(it)=>`Close primes (Fermat) — private key recoverable (${it} iters)`,
f_roca:"Possible ROCA fingerprint — needs deeper check (CVE-2017-15361)",
f_shared:(w)=>`🔗 Shared prime (${w}) — private key recoverable`,
key_n:(i,b)=>`Key #${i} · ${b}bit`,
shared_title:"🔗 Shared primes found — these keys can recover each other's private key",
shared_row:(a,b,bits)=>`${bits}-bit shared prime — both recoverable (private key value not shown)`,
shared_pair:(a,b)=>`Key #${a} ↔ Key #${b}`,
noshare_t:"No shared primes", noshare_d:(n)=>`The ${n} keys you entered do not share any prime (batch-GCD check complete).`,
single_t:"Shared-prime check needs 2+ keys", single_d:"Paste public keys from several devices to check for shared primes.",
al_consent:"Please check the ownership/authorization box.", al_nokey:"No valid RSA public key found. Please check the format.",
busy:"Checking…",
cr_label:"Recovered primes (this key is already broken)", cr_time:"Recovered in", cr_iter:"Fermat iters", cr_via:"Recovered via", cr_note:"anyone can recover these from the public modulus → retire this key now",
vd_bad:(n)=>`${n} KEY${n>1?'S':''} AT HIGH RISK`, vd_bad_sub:"Dangerous length or exponent. Replace these keys.", vd_cracked:(n)=>`${n} KEY${n>1?'S':''} CRACKED`, vd_cracked_sub:"The private key was recovered. Retire and replace these keys immediately.",
vd_weak:(n)=>`${n} key(s) need attention`, vd_weak_sub:"Not breakable right now, but replacement is recommended.",
vd_safe:"All safe", vd_safe_sub:"None of the four defects this tool checks were found.",
tab_check:"🔎 Self-check", tab_bench:"🏆 Benchmark", tab_addr:"🌐 Check an address", lc_ph_h:"🚪 About port 443", lc_p1:"443 is the door used by HTTPS. This check can only see devices whose door is open to the internet.", lc_p2:"Home and office routers or carriers usually keep it closed, so no response for your own IP is common. It is not a fault.", lc_p3:"No response means the key was not seen. It is not a Safe verdict. Check devices inside your network as shown below.", lc_p4:"Do not open port 443 on your router just for this check. Closed is safer.", lc_lh:"🏠 Local collector (devices inside your home or office)", lc_l1:"Download and run the script. It reads public keys only, in the private network of this PC, and prints Safe, Caution or Danger. Type YES when asked. No login attempts and no internet traffic.", lc_l2:"(Optional) Open keyguard_keys.txt from the same folder in the Self-check tab to see the details in your browser.", lc_lw:"Download for Windows", lc_lp:"Download for macOS · Linux (Python 3)", lc_src:"View code", lc_run:"Run", lc_one:"Quick check of a single device", lc_auth:"Use it only on networks you own or are authorized to test.", lc_file:"📂 Open file", gd_h:"🏠 Check a device inside your home or office", gd_s1:"Run this command on a PC in the same network. Replace the address with your router, camera or printer.", gd_s2:"Paste the printed certificate into the Self-check tab. Paste several devices together to compare them. Pasted text never leaves your browser.", gd_copy:"Copy", gd_copied:"Copied", gd_go:"Go to Self-check", ad_h:"🌐 Check a domain or IP", ad_hint:"Our server connects only to port 443 (HTTPS) of the address and fetches its public certificate. The verdict is computed in this browser. Nothing is logged. The public certificate stays in memory for 10 minutes.", ad_ph:"e.g. example.com or 203.0.113.10", ad_my:"📍 Use my IP", ad_consent:"The device at this address is mine or I am authorized to test it. I will not test anyone else's device without permission.", ad_run:"Check address", ad_clear:"Clear list", ad_more:"Check more devices one by one. They are added to the list and compared with each other for shared primes. Private addresses (192.168.x.x and similar) cannot be reached from the internet, so paste their certificates in the Self-check tab.", ad_self:"self-signed", ad_exp:"expires", ad_issuer:"issuer", ad_got:"Your access IP is filled in. Tick the authorization box and run the check.", ad_ec:"This device uses an elliptic-curve key, so the RSA checks do not apply.", ad_other:"This is not an RSA key, so the RSA checks do not apply.", ad_noaddr:"Please enter an address.", ad_err:{"bad_target": "Check the address. Enter one domain or IP, with no port or path.", "private_target": "Private addresses cannot be reached from the internet. Check the device from this PC as shown below.", "dns": "The address could not be resolved.", "connect": "Port 443 is closed. The key of this device cannot be seen from the internet. This is not a Safe verdict.", "timeout": "This device is not visible from the internet (no response on port 443). It is not a fault. Its key cannot be seen from outside. This is not a Safe verdict.", "tls": "A TLS connection could not be established.", "rate": "Too many requests. Please try again shortly.", "consent": "Please tick the authorization box.", "server": "The check server is waking up. Please try again in about a minute.", "nomyip": "Your access IP could not be determined."},
lb_eye:"Measured on Spark · no cherry-picking", lb_h:"Weak-Key Detection Benchmark",
lb_lead:"Recall, false-positive rate and speed of detection methods on a standard weak-key set, ranked. Single methods catch only part; combined KeyGuard catches every type.",
th_det:"Detector", th_recall:"Recall", th_fpr:"False-pos", th_time:"Time", th_cat:"Per-category",
lb_read:"Recall = % of real weak keys caught; false-pos = % of healthy keys wrongly flagged. Classical factoring (Trial, Pollard) scores 0% on 2048-bit — detection is about structural defects, not factoring.",
lb_method_eye:"Methodology (145 keys · fixed seed · reproducible)",
lb_m1h:"80 negatives / 65 positives", lb_m1d:"80 healthy 2048 + 65 weak (close, shared, short, exponent)",
lb_m2h:"Same conditions", lb_m2d:"Every detector runs the same 145 keys on the same machine (Spark)",
lb_m3h:"Reproducible", lb_m3d:"Fixed seed (20262025) — reproduces the set anytime, no tampering",
lb_notes:["ROCA shows 0% (no synthetic ROCA positives in this set; included for completeness).","Classical factoring is 0% (2048-bit infeasible; measured within an iteration cap).","Small self-generated set — numbers are measured values only, no exaggeration."],
catlabel:{close:"Close",shared:"Shared",short:"Short",bade:"Exp"}, me_tag:"OURS",
sample:{fermat:["🤏 Close primes","2048-bit key with primes too close — factored instantly by Fermat"],shared:["🔗 Shared prime (2 devices)","Two devices share a prime — both broken by batch-GCD"],short:["📏 Key too short","512-bit — within factorable range"],bade:["⚠️ Bad exponent","Public exponent e=2 (misconfigured)"],safe:["✓ Healthy key","A well-generated real 2048-bit certificate key — safe"],mix:["🎯 Mix everything","All types at once — full report"]}
},
zh:{
tag:"粘贴的密钥 100% 在浏览器内检测 · 绝不发送到服务器",
h1a:"你设备的加密密钥,", h1b:"会不会是次品?",
lead:"如果工厂错误地给多台设备出厂了相同的秘密素数,任何人只要找到它就能打开所有这些设备。KeyGuard 用数学在 30 秒内检测你的公钥是否就是这种次品密钥。",
sub:"只粘贴公钥,不要粘贴私钥。公钥本来就是公开的,所以这是安全的。",
about_h:"这是什么?",
about_p1:"RSA 密钥是'由两个大素数相乘得到的锁'。知道这两个素数就能开锁——通常无法找到它们,所以是安全的。问题出在随机性差的廉价设备在开机后立即生成密钥时。",
about_p2:"当两台不同设备碰巧使用了相同的素数,或两个素数取得太接近时,仅凭公钥就能还原出私钥。KeyGuard 正是找出这类'结构性缺陷密钥'——不是因为算法弱,而是因为某些实现有缺陷。",
about_k1h:"🔗 素数共享 (batch-GCD)", about_k1d:"多台设备复用同一素数 → 一次求最大公约数即可还原双方私钥",
about_k2h:"🤏 相近素数 (Fermat)", about_k2d:"若两素数过于接近,即使 2048 位也能瞬间分解",
about_k3h:"🧬 ROCA (CVE-2017-15361)", about_k3d:"检测某些缺陷芯片生成的易受攻击密钥模式",
about_k4h:"📏 过短/弱密钥", about_k4d:"≤768 位(可分解)、<2048(建议更换)、异常指数",
chk_h:"🔎 公钥自检",
chk_hint:"每行粘贴一个 RSA 公钥。格式:PEM(-----BEGIN PUBLIC KEY-----)、十六进制模数、十进制 N、或 N:e。把多台设备的密钥一起粘贴可同时检测是否共享素数。",
chk_sample:"⚡ 懒得输入?点击一个示例类型,立即查看结果",
chk_ph:"例如)\n-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqh...\n-----END PUBLIC KEY-----\n\n或十六进制模数:\nC897A647627FAEBB...\n\n或 N:e 形式:\n2533...9077 : 65537",
chk_consent:"我要检测的公钥属于我拥有或已获授权检测的设备。我不会未经许可检测他人的设备或密钥。",
chk_run:"运行自检", chk_clear:"清除",
chk_note:"所有检测完全在你的浏览器内运行。任何密钥都不会被存储或发送到服务器(可用'清除'立即清空输入),即使是可破解的密钥,也绝不显示还原出的私钥值,只告知'可被还原'这一事实。",
how_eye:"如何使用", how_h:"三步搞定",
how1h:"1. 粘贴公钥", how1d:"粘贴你的服务器、路由器、IoT 设备的公钥(证书 / SSH 公钥)。切勿粘贴私钥。",
how2h:"2. 运行", how2d:"浏览器立即运行数学检测。无网络传输——全部在你的设备内。",
how3h:"3. 查看结果", how3d:"安全 / 注意 / 危险 一目了然。若危险,会告诉你原因。",
what_eye:"检测什么", what_h:"四种致命缺陷",
w1h:"过短的密钥", w1d:"≤768 位如今可分解,<2048 建议更换。",
w2h:"相近素数 (Fermat)", w2d:"若两素数过于接近,即使 2048 位也瞬间被破。",
w3h:"素数共享 (batch-GCD)", w3d:"若设备共享素数,一次求最大公约数即可打开双方。",
w4h:"ROCA 缺陷芯片", w4d:"检测某些芯片(CVE-2017-15361)生成的易受攻击密钥。",
proof_eye:"已验证", proof_h:"已在真实大规模公钥上完成验证",
proof_lead:"精确检出植入的弱密钥,并在证书透明度(CT)日志的 100 万+ 真实公钥上以 12 分钟完成了大规模验证。",
proof_s1:"对植入弱密钥的检出准确率(0 误报)", proof_s2:"分析的真实 CT 公钥(在 Spark 上)", proof_s3:"粘贴的密钥发送到服务器(全部在客户端)",
proof_note:"注:公共 CT 日志中的网站证书通常生成良好,弱密钥很少见。弱密钥主要存在于嵌入式/IoT 设备的自签名证书中——这正是用本工具检测'你自己的设备'的意义所在。",
faq_eye:"常见问题", faq_h:"你可能想问",
faq1q:"我的私钥会泄露吗?", faq1a:"不会。你只粘贴公钥,而且它也不会离开你的浏览器。",
faq2q:"为什么仅凭公钥就能知道会被破解?", faq2a:"公钥里含有两个素数的'乘积'。若素数相近或共享,仅凭该乘积就能还原它们。",
faq3q:"可以一次粘贴多台设备吗?", faq3a:"可以,建议如此。素数共享检测需要同时粘贴多个密钥。",
faq4q:"显示安全就 100% 放心吗?", faq4a:"意味着本工具检测的四种缺陷不存在。加密的其他方面需要单独审查。",
faq_warn:"⚠️ 本工具仅可用于你拥有或已获授权检测的设备公钥。未经许可检测或入侵他人系统是违法的。",
foot1:"KeyGuard · 公钥自检 · 粘贴检测仅在你的浏览器内运行",
foot2:"用于教育及自有资产检测 · 遵循负责任披露(Responsible Disclosure)原则",
b_safe:"安全", b_weak:"注意", b_bad:"危险",
s_tot:"已检测密钥", s_safe:"安全", s_warn:"注意", s_bad:"危险",
f_nodefect:"无已知缺陷",
f_size_c:(b)=>`密钥长度 ${b} 位 — 处于可分解范围`,
f_size_w:(b)=>`密钥长度 ${b} 位 — 不足 2048,建议更换`,
f_exp:(e)=>`公开指数 e=${e} 异常`,
f_fermat:(it)=>`相近素数(Fermat) — 私钥可还原(${it} 次迭代)`,
f_roca:"疑似 ROCA 指纹 — 需进一步检测 (CVE-2017-15361)",
f_shared:(w)=>`🔗 素数共享 (${w}) — 私钥可还原`,
key_n:(i,b)=>`密钥 #${i} · ${b}bit`,
shared_title:"🔗 发现素数共享 — 以下密钥可互相还原对方私钥",
shared_row:(a,b,bits)=>`${bits} 位素数共享 — 双方均可还原(不显示私钥值)`,
shared_pair:(a,b)=>`密钥 #${a} ↔ 密钥 #${b}`,
noshare_t:"无素数共享", noshare_d:(n)=>`你输入的 ${n} 个密钥彼此不共享素数(batch-GCD 检测完成)。`,
single_t:"素数共享检测需要 2 个以上密钥", single_d:"把多台设备的公钥一起粘贴可检测是否共享素数。",
al_consent:"请勾选所有权/授权确认项。", al_nokey:"未找到有效的 RSA 公钥,请检查格式。",
busy:"检测中…",
cr_label:"已还原的素因子(此密钥已被攻破)", cr_time:"还原耗时", cr_iter:"Fermat 迭代", cr_via:"还原途径", cr_note:"仅凭公开模数任何人都能还原 → 请立即废弃此密钥",
vd_bad:(n)=>`${n} 个高风险密钥`, vd_bad_sub:"长度或指数存在风险,请更换密钥。", vd_cracked:(n)=>`${n} 个密钥被攻破 — CRACKED`, vd_cracked_sub:"私钥已被还原。请立即废弃并更换这些密钥。",
vd_weak:(n)=>`${n} 个密钥需注意`, vd_weak_sub:"目前不会被破解,但建议更换。",
vd_safe:"全部安全", vd_safe_sub:"未发现本工具检测的四种缺陷。",
tab_check:"🔎 自检", tab_bench:"🏆 基准", tab_addr:"🌐 按地址检测", lc_ph_h:"🚪 关于 443 端口", lc_p1:"443 是 HTTPS 使用的门。本检测只能看到向互联网开放此门的设备。", lc_p2:"家庭或办公室路由器和运营商通常会关闭它,因此「我的 IP」无响应很常见,这不是故障。", lc_p3:"无响应表示没有看到密钥,不是安全判定。内部设备请按下面的方法检测。", lc_p4:"请不要为了检测而在路由器上开放 443 端口。关闭更安全。", lc_lh:"🏠 本地采集器(家庭或公司内部的设备)", lc_l1:"下载并运行脚本。它只读取本机所在内网的公钥,并直接显示安全、注意或危险。提示时输入 YES。不尝试登录,不向互联网发送数据。", lc_l2:"(可选)在自检页用「打开文件」载入同一文件夹中的 keyguard_keys.txt,可在浏览器中查看详情。", lc_lw:"下载:Windows", lc_lp:"下载:macOS · Linux(Python 3)", lc_src:"查看代码", lc_run:"运行", lc_one:"快速检测单台设备", lc_auth:"仅在你拥有或已获授权检测的网络中使用。", lc_file:"📂 打开文件", gd_h:"🏠 检测家庭或公司内部的设备", gd_s1:"在同一网络的电脑上运行以下命令。请把地址换成要检测的路由器、摄像头或打印机。", gd_s2:"把输出的证书粘贴到自检页。同时粘贴多台设备可相互比较。粘贴的内容不会离开浏览器。", gd_copy:"复制", gd_copied:"已复制", gd_go:"前往自检", ad_h:"🌐 按域名或 IP 检测", ad_hint:"检测服务器只连接该地址的 443 端口(HTTPS),取得其公开证书。判定在本浏览器内完成。不留记录,公开证书仅在内存中保留 10 分钟。", ad_ph:"例如 example.com 或 203.0.113.10", ad_my:"📍 填入我的 IP", ad_consent:"该地址的设备归我所有或我已获授权检测。我不会未经许可检测他人的设备。", ad_run:"检测地址", ad_clear:"清空列表", ad_more:"可逐个检测更多设备,结果会加入列表并相互比较是否共享素数。内网地址(192.168.x.x 等)无法从互联网访问,请在自检页粘贴其证书。", ad_self:"自签名", ad_exp:"到期", ad_issuer:"签发", ad_got:"已填入你的访问 IP。请勾选授权确认后开始检测。", ad_ec:"该设备使用椭圆曲线密钥,不适用 RSA 检测。", ad_other:"不是 RSA 密钥,不适用 RSA 检测。", ad_noaddr:"请输入地址。", ad_err:{"bad_target": "请检查地址格式。只能输入一个域名或 IP,不含端口和路径。", "private_target": "内网地址无法从互联网访问,请按以下方法在本机检测。", "dns": "无法解析该地址。", "connect": "443 端口已关闭,外部看不到该设备的密钥。这不是安全判定。", "timeout": "该设备在互联网上不可见(443 无响应)。这不是故障,表示外部看不到其密钥。这不是安全判定。", "tls": "无法建立 TLS 连接。", "rate": "请求过多,请稍后再试。", "consent": "请勾选授权确认。", "server": "检测服务器正在唤醒,请约一分钟后重试。", "nomyip": "无法确定你的访问 IP。"},
lb_eye:"在 Spark 实测 · 无挑选", lb_h:"弱密钥检测基准",
lb_lead:"在标准弱密钥测试集上实测各检测方法的召回率、误报率与速度并排名。单一方法只能检出部分,组合的 KeyGuard 可检出所有类型。",
th_det:"检测器", th_recall:"召回率", th_fpr:"误报", th_time:"耗时", th_cat:"按类型",
lb_read:"召回率=真实弱密钥检出%,误报=正常密钥误判%。经典分解(Trial·Pollard)在 2048 位上为 0% — 检测是找结构缺陷而非分解。",
lb_method_eye:"方法论(145 密钥 · 固定种子 · 可复现)",
lb_m1h:"阴性 80 / 阳性 65", lb_m1d:"80 正常 2048 + 65 弱密钥(相近·共享·过短·指数)",
lb_m2h:"相同条件", lb_m2d:"所有检测器在同一机器(Spark)处理相同的 145 密钥",
lb_m3h:"可复现", lb_m3d:"固定种子(20262025) — 随时复现,不可篡改",
lb_notes:["ROCA 为 0%(本集无合成 ROCA 阳性,为完整性而列入)。","经典分解为 0%(2048 位不可行,在迭代上限内测量)。","小规模自建集 — 数字仅为实测值,无夸大。"],
catlabel:{close:"相近",shared:"共享",short:"过短",bade:"指数"}, me_tag:"我们",
sample:{fermat:["🤏 相近素数","两素数过近的 2048 位密钥 — 被 Fermat 瞬间分解"],shared:["🔗 素数共享 (2台)","两台设备共享素数 — 被 batch-GCD 同时攻破"],short:["📏 密钥过短","512 位 — 处于可分解范围"],bade:["⚠️ 异常指数","公开指数 e=2(配置错误)"],safe:["✓ 正常密钥","生成良好的真实 2048 位证书密钥 — 安全"],mix:["🎯 全部混合","一次检测以上所有类型 — 综合报告"]}
}
};
let LANG='ko';
function t(k){return (I18N[LANG]&&I18N[LANG][k])!=null?I18N[LANG][k]:I18N.en[k];}
function applyLang(){
document.documentElement.setAttribute('lang',LANG);
document.querySelectorAll('[data-i18n]').forEach(el=>{const v=t(el.getAttribute('data-i18n'));if(typeof v==='string')el.textContent=v;});
document.querySelectorAll('[data-i18n-ph]').forEach(el=>{const v=t(el.getAttribute('data-i18n-ph'));if(typeof v==='string')el.setAttribute('placeholder',v);});
document.querySelectorAll('#langsw button').forEach(b=>b.classList.toggle('on',b.dataset.lang===LANG));
renderChips();renderBoard();
if(typeof ADDR!=='undefined'&&ADDR.length)renderAddr();
}
function detectLang(){
try{const s=localStorage.getItem('kg-lang');if(s&&I18N[s])return s;}catch(e){}
const n=(navigator.language||navigator.userLanguage||'en').toLowerCase();
if(n.startsWith('ko'))return 'ko';
if(n.startsWith('zh'))return 'zh';
return 'en';
}
/* ================= crypto engine ================= */
function bi(x){return BigInt(x);}
function bgcd(a,b){a=a<0n?-a:a;b=b<0n?-b:b;while(b){[a,b]=[b,a%b];}return a;}
function bisqrt(n){if(n<0n)return -1n;if(n<2n)return n;let x=n,y=(x+1n)/2n;while(y<x){x=y;y=(x+n/x)/2n;}return x;}
function bitlen(n){return n.toString(2).length;}
function fermat(n,maxIter){
if(n%2n===0n)return {p:2n,q:n/2n,iter:0};
let a=bisqrt(n);if(a*a<n)a+=1n;
for(let i=0;i<maxIter;i++){let b2=a*a-n;if(b2>=0n){let b=bisqrt(b2);if(b*b===b2){let p=a-b,q=a+b;if(p>1n&&p*q===n)return{p,q,iter:i};}}a+=1n;}
return null;
}
const ROCA_PRIMES=[3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,151,163,167];
function rocaHeuristic(n){try{for(const p of ROCA_PRIMES){const P=bi(p);let res=new Set();let x=1n;for(let k=1;k<p;k++){x=(x*65537n)%P;res.add(x.toString());}const r=(n%P);if(r!==0n&&!res.has(r.toString()))return false;}return true;}catch(e){return false;}}
function b64ToBytes(b64){const bin=atob(b64.replace(/\s+/g,''));const a=new Uint8Array(bin.length);for(let i=0;i<bin.length;i++)a[i]=bin.charCodeAt(i);return a;}
function derIntegers(bytes){const out=[];let i=0;function len(){let l=bytes[i++];if(l&0x80){let k=l&0x7f;l=0;while(k--)l=(l<<8)|bytes[i++];}return l;}function walk(end){while(i<end){const tag=bytes[i++];const l=len();const s=i;if(tag===0x02){let hex='';for(let j=s;j<s+l;j++)hex+=bytes[j].toString(16).padStart(2,'0');if(hex)out.push(BigInt('0x'+hex));i=s+l;}else if(tag===0x30||tag===0x31||tag===0x03){walk(s+l);i=s+l;}else{i=s+l;}}}try{walk(bytes.length);}catch(e){}return out;}
const RSA_OID=[0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x01];
function rsaFromDer(by){let o=-1;for(let i=0;i+RSA_OID.length<=by.length;i++){let m=true;for(let j=0;j<RSA_OID.length;j++)if(by[i+j]!==RSA_OID[j]){m=false;break;}if(m){o=i+RSA_OID.length;break;}}
let ints;if(o<0){ints=derIntegers(by);}else{let i=o;if(by[i]===0x05&&by[i+1]===0x00)i+=2;if(by[i]!==0x03)return null;i++;let l=by[i++];if(l&0x80){let k=l&0x7f;l=0;while(k--)l=(l<<8)|by[i++];}if(by[i]!==0x00)return null;ints=derIntegers(by.slice(i+1,i+l));}
return ints.length>=2?{n:ints[0],e:ints[1]}:null;}
function sshRsa(line){const m=line.match(/^ssh-rsa\s+([A-Za-z0-9+\/=]+)/);if(!m)return null;const by=b64ToBytes(m[1]);let i=0;const f=[];while(i+4<=by.length&&f.length<3){const l=((by[i]<<24)|(by[i+1]<<16)|(by[i+2]<<8)|by[i+3])>>>0;i+=4;if(i+l>by.length)return null;f.push(by.slice(i,i+l));i+=l;}
if(f.length<3)return null;const b=x=>{let h='';for(const c of x)h+=c.toString(16).padStart(2,'0');return BigInt('0x'+(h||'0'));};return{n:b(f[2]),e:b(f[1])};}
function parseNum(s){s=s.trim().replace(/\s/g,'');if(/^0x/i.test(s))return BigInt(s);if(/^[0-9]+$/.test(s))return BigInt(s);if(/^[0-9a-fA-F]+$/.test(s))return BigInt('0x'+s);throw 'bad';}
function parseKey(line){line=line.trim();if(!line)return null;if(line.startsWith('ssh-rsa')){try{return sshRsa(line);}catch(e){return null;}}
if(line.includes('BEGIN')){const m=line.match(/-----BEGIN ([^-]+)-----([\s\S]*?)-----END/);if(!m||/PRIVATE/.test(m[1]))return null;try{return rsaFromDer(b64ToBytes(m[2]));}catch(e){return null;}}if(line.includes(':')){const[a,b]=line.split(':');try{return{n:parseNum(a),e:parseNum(b)};}catch(e){return null;}}try{return{n:parseNum(line),e:65537n};}catch(e){return null;}}
function assess(n,e){const bits=bitlen(n);const flags=[];let level='safe';const rec={};
if(bits<=768){level='critical';flags.push(t('f_size_c')(bits));}else if(bits<2048){level='weak';flags.push(t('f_size_w')(bits));}
if(e<3n||e%2n===0n){level='critical';flags.push(t('f_exp')(e));}
const t0=(performance&&performance.now)?performance.now():Date.now();
const f=fermat(n,2000);const ms=((performance&&performance.now)?performance.now():Date.now())-t0;
if(f){level='critical';flags.push(t('f_fermat')(f.iter));rec.p=f.p;rec.q=f.q;rec.method='fermat';rec.iter=f.iter;rec.ms=ms;}
if(bits>=512&&rocaHeuristic(n)){if(level==='safe')level='weak';flags.push(t('f_roca'));}
return{bits,level,flags,factored:!!f,rec};}
function midEllip(s,head,tail){s=String(s);return s.length>head+tail+3?s.slice(0,head)+'…'+s.slice(-tail):s;}
function crackHTML(rec,bits){
if(!rec||!rec.p)return '';
const p=midEllip(rec.p.toString(),14,8), q=midEllip(rec.q.toString(),14,8);
const stat=rec.method==='fermat'
? `<span>${esc(t('cr_time'))} <b>${rec.ms.toFixed(1)}ms</b></span><span>${esc(t('cr_iter'))} <b>${rec.iter}</b></span>`
: `<span>${esc(t('cr_via'))} <b>batch-GCD</b></span>`;
return `<div class="crack"><div class="cl">🔓 ${esc(t('cr_label'))}</div>`+
`<div class="eq">N <span class="op">=</span> <span class="p">${esc(p)}</span> <span class="op">×</span> <span class="p">${esc(q)}</span></div>`+
`<div class="st">${stat}<span>${esc(t('cr_note'))}</span></div></div>`;}
/* ================= UI ================= */
const $=id=>document.getElementById(id);
function esc(s){return String(s).replace(/[&<>]/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;'}[c]));}
const sleep=ms=>new Promise(r=>setTimeout(r,ms));let BUSY=false;
async function runCheck(){
if(BUSY)return;
if(!$('consent').checked){alert(t('al_consent'));return;}
BUSY=true;const btn=$('runbtn');const prev=btn.textContent;btn.textContent=t('busy');btn.style.opacity='.7';
$('checker').appendChild($('results'));await sleep(30);try{await doCheck();}finally{btn.textContent=prev;btn.style.opacity='1';BUSY=false;}
}
async function doCheck(src){
const lines=(src==null?$('keyin').value:src).split('\n');const blocks=[],labs=[];let buf='',lab='';const put=b=>{blocks.push(b);labs.push(lab);lab='';};
for(const ln of lines){if(!buf&&/^\s*#/.test(ln)){lab=ln.replace(/^\s*#\s*/,'').trim().slice(0,80);continue;}if(ln.includes('BEGIN'))buf=ln+'\n';else if(buf){buf+=ln+'\n';if(ln.includes('END')){put(buf);buf='';}}else if(ln.trim())put(ln);}
const parsed=[];blocks.forEach((b,i)=>{const k=parseKey(b);if(k&&k.n>1n)parsed.push({idx:i+1,lab:labs[i],...k});});
if(!parsed.length){$('results').style.display='none';alert(t('al_nokey'));return;}
const shared=[];const sharedMap={};const sharedG={};
for(let a=0;a<parsed.length;a++)for(let b=a+1;b<parsed.length;b++){const g=bgcd(parsed[a].n,parsed[b].n);if(g!==1n&&g!==parsed[a].n&&g!==parsed[b].n){const bits=bitlen(g);shared.push([parsed[a].idx,parsed[b].idx,bits]);(sharedMap[parsed[a].idx]=sharedMap[parsed[a].idx]||[]).push(parsed[b].idx);(sharedMap[parsed[b].idx]=sharedMap[parsed[b].idx]||[]).push(parsed[a].idx);sharedG[parsed[a].idx]=g;sharedG[parsed[b].idx]=g;}}
let nSafe=0,nWeak=0,nBad=0,nCracked=0;const rows=[];
for(const k of parsed){await sleep(0);const r=assess(k.n,k.e);
if(sharedMap[k.idx]){r.level='critical';r.flags.unshift(t('f_shared')(sharedMap[k.idx].map(x=>'#'+x).join(', ')));if(!r.rec.p){const g=sharedG[k.idx];r.rec={p:g,q:k.n/g,method:'shared'};}}
if(r.level==='safe')nSafe++;else if(r.level==='weak')nWeak++;else nBad++;if(r.rec.p)nCracked++;
const emoji=r.level==='safe'?'✓':r.level==='weak'?'!':'✕';const badge=r.level==='safe'?t('b_safe'):r.level==='weak'?t('b_weak'):t('b_bad');
rows.push(`<div class="res ${r.level}"><div class="ic">${emoji}</div><div class="body"><div class="tt">${esc(t('key_n')(k.idx,r.bits))}${k.lab?' · '+esc(k.lab):''}</div><div class="ds">${r.flags.length?esc(r.flags.join(' / ')):esc(t('f_nodefect'))}</div>${crackHTML(r.rec,r.bits)}</div><span class="badge">${badge}</span></div>`);}
// 극적 판정 배너
if(nBad>0&&nCracked===0){$('verdict').innerHTML=`<div class="verdict bad"><div class="big">${esc(t('vd_bad')(nBad))}</div><div class="sub2">${esc(t('vd_bad_sub'))}</div></div>`;}
else if(nBad>0){$('verdict').innerHTML=`<div class="verdict bad"><div class="lock">🔓</div><div class="big">${esc(t('vd_cracked')(nCracked))}</div><div class="sub2">${esc(t('vd_cracked_sub'))}</div></div>`;}
else if(nWeak>0){$('verdict').innerHTML=`<div class="verdict bad" style="border-color:var(--warn);background:radial-gradient(120% 140% at 50% 0,rgba(251,191,36,.18),transparent)"><div class="big" style="color:var(--warn)">${esc(t('vd_weak')(nWeak))}</div><div class="sub2">${esc(t('vd_weak_sub'))}</div></div>`;}
else{$('verdict').innerHTML=`<div class="verdict safe"><div class="big">🛡️ ${esc(t('vd_safe'))}</div><div class="sub2">${esc(t('vd_safe_sub'))}</div></div>`;}
$('summary').innerHTML=`<div class="card stat tot"><div class="n">${parsed.length}</div><div class="l">${esc(t('s_tot'))}</div></div><div class="card stat ok"><div class="n">${nSafe}</div><div class="l">${esc(t('s_safe'))}</div></div><div class="card stat warn"><div class="n">${nWeak}</div><div class="l">${esc(t('s_warn'))}</div></div><div class="card stat bad"><div class="n">${nBad}</div><div class="l">${esc(t('s_bad'))}</div></div>`;
$('reslist').innerHTML=rows.join('');
if(shared.length){$('sharedbox').innerHTML=`<div class="shared"><h3>${esc(t('shared_title'))}</h3>`+shared.map(s=>`<div class="res critical"><div class="ic">✕</div><div class="body"><div class="tt">${esc(t('shared_pair')(s[0],s[1]))}</div><div class="ds">${esc(t('shared_row')(s[0],s[1],s[2]))}</div></div><span class="badge">${t('b_bad')}</span></div>`).join('')+`</div>`;}
else if(parsed.length>=2){$('sharedbox').innerHTML=`<div class="res safe" style="margin-top:12px"><div class="ic">✓</div><div class="body"><div class="tt">${esc(t('noshare_t'))}</div><div class="ds">${esc(t('noshare_d')(parsed.length))}</div></div><span class="badge">${t('b_safe')}</span></div>`;}
else{$('sharedbox').innerHTML=`<div class="res safe" style="margin-top:12px;opacity:.75"><div class="ic">ℹ</div><div class="body"><div class="tt">${esc(t('single_t'))}</div><div class="ds">${esc(t('single_d'))}</div></div></div>`;}
$('results').style.display='block';$('results').scrollIntoView({behavior:'smooth',block:'start'});
}
function renderChips(){const box=$('schips');if(!box||typeof SAMPLES==='undefined')return;const order=['fermat','shared','short','bade','safe','mix'];const sm=t('sample');
box.innerHTML=order.map(k=>`<button class="schip ${k==='mix'?'mix':''}" data-k="${k}"><span class="st">${esc(sm[k][0])}</span><span class="sd">${esc(sm[k][1])}</span></button>`).join('');
box.querySelectorAll('.schip').forEach(b=>b.onclick=()=>{const s=SAMPLES[b.dataset.k];$('keyin').value=s.keys.join('\n');$('consent').checked=true;runCheck();});}
$('clearbtn').onclick=()=>{$('keyin').value='';$('results').style.display='none';};
$('runbtn').onclick=runCheck;
async function loadFiles(fs){let o=[];for(const f of [...fs].slice(0,20)){if(f.size>2000000)continue;const x=(await f.text()).replace(/^\ufeff/,'');if(/PRIVATE KEY/.test(x))continue;o.push(/^\s*#/.test(x)?x:'# '+f.name+'\n'+x);}if(o.length)$('keyin').value=o.join('\n');}
$('filebtn').onclick=()=>$('filein').click();$('filein').onchange=async e=>{await loadFiles(e.target.files);e.target.value='';};
$('keyin').addEventListener('dragover',e=>e.preventDefault());$('keyin').addEventListener('drop',async e=>{if(e.dataTransfer.files.length){e.preventDefault();await loadFiles(e.dataTransfer.files);}});
document.querySelectorAll('#langsw button').forEach(b=>b.onclick=()=>{LANG=b.dataset.lang;try{localStorage.setItem('kg-lang',LANG);}catch(e){}applyLang();});
$('themeToggle').onclick=()=>{const r=document.documentElement;r.setAttribute('data-theme',r.getAttribute('data-theme')==='dark'?'light':'dark');try{localStorage.setItem('kg-theme',r.getAttribute('data-theme'));}catch(e){}};
try{const th=localStorage.getItem('kg-theme');if(th)document.documentElement.setAttribute('data-theme',th);}catch(e){}
/* ===== leaderboard ===== */
function catColor(p){if(p>=100)return 'rgba(52,211,153,.9)';if(p>=50)return 'rgba(251,191,36,.9)';if(p>0)return 'rgba(251,146,60,.9)';return 'rgba(127,127,127,.25)';}
function renderBoard(){
if(typeof BENCH==='undefined'||!$('lbrows'))return;
const m=BENCH.meta;const lab={t_keys:{ko:"총 키",en:"total keys",zh:"总密钥"},t_vuln:{ko:"취약",en:"weak",zh:"弱"},t_clean:{ko:"정상",en:"healthy",zh:"正常"},t_det:{ko:"탐지기",en:"detectors",zh:"检测器"}};
const L=I18N[LANG]?LANG:'en';
$('lbmeta').innerHTML=`<div class="m"><div class="n">${m.total}</div><div class="l">${lab.t_keys[L]}</div></div><div class="m"><div class="n v">${m.vuln}</div><div class="l">${lab.t_vuln[L]}</div></div><div class="m"><div class="n c">${m.clean}</div><div class="l">${lab.t_clean[L]}</div></div><div class="m"><div class="n">${BENCH.rows.length}</div><div class="l">${lab.t_det[L]}</div></div>`;
const cats=["close","shared","short","bade"];const cl=t('catlabel');
$('lbrows').innerHTML=BENCH.rows.map((r,i)=>{
const win=i===0?'win':'';const me=r.name.includes('ours')?`<span class="me">${t('me_tag')}</span>`:'';
const nm=esc(r.name.replace(' (ours · combined)',' ').replace('-only',L==='ko'?' 단독':L==='zh'?' 单独':'-only').replace('(classical)',L==='ko'?'(고전)':L==='zh'?'(经典)':'(classical)'));
const cc=cats.map(c=>`<div class="cc" title="${cl[c]} ${r.percat[c]}%" style="background:${catColor(r.percat[c])};color:#0a0b14">${r.percat[c]}</div>`).join('');
const tm=r.time_s<1?(r.time_s*1000).toFixed(0)+'ms':r.time_s.toFixed(1)+'s';
return `<tr class="${win}"><td class="rank">${i+1}</td><td><span class="dname">${nm}${me}</span></td><td><div class="bar"><span style="width:${r.recall}%"></span><b>${r.recall}%</b></div></td><td class="fpr ${r.fpr==0?'z':'n'}">${r.fpr}%</td><td class="mono">${tm}</td><td><div class="cats">${cc}</div></td></tr>`;
}).join('');
$('lbnotes').innerHTML=t('lb_notes').map(n=>`<li>${esc(n)}</li>`).join('');
}
/* ===== address check ===== */
const API="https://final-bench-keyguard-api.hf.space/";let ADDR=[];let WOKE=false;
function adMsg(x){const m=$('addrmsg');m.textContent=x||'';m.style.display=x?'block':'none';}
function guide(host){const g=$('guide');if(host===undefined)return;
const h=/^(10|192\.168|172\.(1[6-9]|2\d|3[01]))(\.\d{1,3}){2,3}$/.test(host)?host:'192.168.0.1';
$('cmdwin').value=`$h='${h}';$c=New-Object Net.Sockets.TcpClient($h,443);$s=New-Object Net.Security.SslStream($c.GetStream(),$false,{$true});$s.AuthenticateAsClient($h);'-----BEGIN CERTIFICATE-----';[Convert]::ToBase64String($s.RemoteCertificate.GetRawCertData(),1);'-----END CERTIFICATE-----'`;
$('cmdnix').value=`openssl s_client -connect ${h}:443 </dev/null 2>/dev/null | openssl x509`;if(host)g.scrollIntoView({behavior:'smooth',block:'nearest'});}
document.querySelectorAll('.cp').forEach(b=>b.onclick=async()=>{const e=$(b.dataset.for);e.select();let ok=false;try{await navigator.clipboard.writeText(e.value);ok=true;}catch(x){try{ok=document.execCommand('copy');}catch(y){}}if(ok){b.textContent=t('gd_copied');setTimeout(()=>b.textContent=t('gd_copy'),1500);}});
$('gogo').onclick=()=>{showTab('check');$('keyin').scrollIntoView({block:'center'});$('keyin').focus();};
function adErr(c){const e=t('ad_err');return e[c]||e.tls;}
function renderAddr(){let n=0;$('addrlist').innerHTML=ADDR.map(a=>{const rs=a.type==='RSA'&&a.key;const no=rs?'#'+(++n):'ℹ';
const meta=[a.type+(a.key?' '+bitlen(a.key.n):a.bits?' '+a.bits:''),a.tls,a.self_signed?t('ad_self'):(a.issuer?t('ad_issuer')+' '+a.issuer:''),a.not_after?t('ad_exp')+' '+a.not_after:''].filter(Boolean).join(' · ');
return `<div class="addrrow"><span>${no}</span><b>${esc(a.target)}</b><span>${esc(meta)}</span>${rs?'':`<span>${esc(a.type==='EC'?t('ad_ec'):a.type==='RSA'?t('al_nokey'):t('ad_other'))}</span>`}</div>`;}).join('');}
async function runAddr(){
if(BUSY)return;const v=$('addrin').value.trim();
if(!v){adMsg(t('ad_noaddr'));return;}
if(!$('consent2').checked){adMsg(adErr('consent'));return;}
BUSY=true;const btn=$('addrbtn');btn.textContent=t('busy');btn.style.opacity='.7';adMsg('');
try{
let j;try{const r=await fetch(API+'api/cert',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({target:v,consent:true})});j=await r.json();}catch(e){j={ok:false,error:'server'};}
if(!j.ok){adMsg(adErr(j.error));if(['timeout','connect','private_target'].includes(j.error))guide(v);return;}
j.key=j.type==='RSA'?parseKey(j.pem):null;
ADDR=ADDR.filter(a=>a.target!==j.target);ADDR.push(j);if(ADDR.length>50)ADDR.shift();
const ks=ADDR.filter(a=>a.key);
if(ks.length){const src=[];ks.forEach(a=>src.push('# '+a.target,a.key.n.toString()+':'+a.key.e.toString()));$('addrres').appendChild($('results'));renderAddr();await doCheck(src.join('\n'));}
else{$('results').style.display='none';renderAddr();}
}finally{btn.textContent=t('ad_run');btn.style.opacity='1';BUSY=false;}
}
$('addrbtn').onclick=runAddr;$('addrin').addEventListener('keydown',e=>{if(e.key==='Enter')runAddr();});
$('addrclear').onclick=()=>{ADDR=[];$('addrin').value='';$('addrlist').innerHTML='';adMsg('');$('results').style.display='none';};
$('myipbtn').onclick=async()=>{try{const j=await(await fetch(API+'api/myip')).json();if(!j.ip||!j.public){adMsg(adErr('nomyip'));return;}$('addrin').value=j.ip;adMsg(t('ad_got'));}catch(e){adMsg(adErr('server'));}};
/* ===== tabs ===== */
function showTab(which){
[['check','tabCheck','tab-check'],['addr','tabAddr','tab-addr'],['bench','tabBench','tab-bench']].forEach(([k,b,p])=>{$(p).style.display=k===which?'block':'none';$(b).classList.toggle('on',k===which);});
if(which==='bench')renderBoard();
if(which==='addr'&&!WOKE){WOKE=true;fetch(API+'api/myip').catch(()=>{});}
try{localStorage.setItem('kg-tab',which);}catch(e){}
}
$('tabCheck').onclick=()=>showTab('check');$('tabAddr').onclick=()=>showTab('addr');$('tabBench').onclick=()=>showTab('bench');
guide('');
LANG=detectLang();applyLang();
try{const tb=localStorage.getItem('kg-tab');if(tb==='bench'||tb==='addr')showTab(tb);}catch(e){}
</script>
</body>
</html>