Skip to content

Instantly share code, notes, and snippets.

@Lewiscowles1986
Last active November 16, 2021 06:22
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Lewiscowles1986/d4c554e503d1ebcb12ebff127383d673 to your computer and use it in GitHub Desktop.
SSH with asymmetric key UML Sequence
Display the source blob
Display the rendered blob
Raw
<svg xmlns="http://www.w3.org/2000/svg" contentScriptType="application/ecmascript" contentStyleType="text/css" height="479" preserveAspectRatio="none" viewBox="0 0 469 479" width="469" zoomAndPan="magnify">
<style>
.a{
height:500px;
width:800px;
}
.b{
font-weight:bold;
}
.c{
stroke-dasharray:5;
stroke:#A80036;
}
.d{
fill:#FEFECE;
stroke-width:2;
stroke:#A80036;
}
.e{
fill:#A80036;
stroke:#A80036;
}
.f{
stroke:#A80036;
}
.g{
stroke-dasharray:2;
stroke:#A80036;
}
</style>
<defs>
<filter height="300" width="300" x="-1" y="-1" id="f14owcelmyttc1">
<feGaussianBlur result="blurOut" stdDeviation="2.0"/>
<feColorMatrix in="blurOut" result="blurOut2" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .4 0"/>
<feOffset dx="4.0" dy="4.0" in="blurOut2" result="blurOut3"/>
<feBlend in="SourceGraphic" in2="blurOut3" mode="normal"/>
</filter>
</defs>
<g xmlns="http://www.w3.org/2000/svg">
<text font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="109" x="175.5" y="23" class="b">
Diffie-Hellman
</text>
<line x1="36" x2="36" y1="68.59" y2="438.82" class="c"/>
<line x1="428.5" x2="428.5" y1="68.59" y2="438.82" class="c"/>
<rect filter="url(#f14owcelmyttc1)" height="30.3" width="53" x="8" y="33.3" class="d"/>
<text font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="39" x="15" y="53.29">
Client
</text>
<rect filter="url(#f14owcelmyttc1)" height="30.3" width="53" x="8" y="437.82" class="d"/>
<text font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="39" x="15" y="457.82">
Client
</text>
<rect filter="url(#f14owcelmyttc1)" height="30.3" width="58" x="397.5" y="33.3" class="d"/>
<text font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="44" x="404.5" y="53.29">
Server
</text>
<rect filter="url(#f14owcelmyttc1)" height="30.3" width="58" x="397.5" y="437.82" class="d"/>
<text font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="44" x="404.5" y="457.82">
Server
</text>
<polygon points="47.5 95.59 37.5 99.59 47.5 103.59 43.5 99.59" class="e"/>
<polygon points="416.5 95.59 426.5 99.59 416.5 103.59 420.5 99.59" class="e"/>
<line x1="41.5" x2="422.5" y1="99.59" y2="99.59" class="f"/>
<text font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="368" x="53.5" y="94.66">
Agree publicly on `prime modulus`(PM) &amp; `generator`(G)
</text>
<line x1="36.5" x2="78.5" y1="128.86" y2="128.86" class="g"/>
<line x1="78.5" x2="78.5" y1="128.86" y2="141.86" class="g"/>
<line x1="37.5" x2="78.5" y1="141.86" y2="141.86" class="g"/>
<polygon points="47.5 137.86 37.5 141.86 47.5 145.86 43.5 141.86" class="e"/>
<text font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="259" x="43.5" y="123.79">
Generate private random number (PRNI)
</text>
<line x1="36.5" x2="78.5" y1="173.5" y2="173.5" class="g"/>
<line x1="78.5" x2="78.5" y1="173.5" y2="186.5" class="g"/>
<line x1="37.5" x2="78.5" y1="186.5" y2="186.5" class="g"/>
<polygon points="47.5 182.5 37.5 186.5 47.5 190.5 43.5 186.5" class="e"/>
<text font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="287" x="43.5" y="168.43">
Generate public random number (PRNS) = G
</text>
<text font-family="sans-serif" font-size="10" lengthAdjust="spacingAndGlyphs" textLength="25" x="330.5" y="163.14">
PRNI
</text>
<text font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="36" x="355.5" y="168.43">
%PM)
</text>
<polygon points="416.5 211.5 426.5 215.5 416.5 219.5 420.5 215.5" class="e"/>
<line x1="36.5" x2="422.5" y1="215.5" y2="215.5" class="g"/>
<text font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="77" x="43.5" y="210.57">
sends PRNS
</text>
<g transform="translate(857.5, 0) scale(-1, 1)">
<line x1="428.5" x2="470.5" y1="244.77" y2="244.77" class="g"/>
<line x1="470.5" x2="470.5" y1="244.77" y2="257.77" class="g"/>
<line x1="429.5" x2="470.5" y1="257.77" y2="257.77" class="g"/>
<polygon points="439.5 253.77 429.5 257.77 439.5 261.77 435.5 257.77" class="e"/>
</g>
<text font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="259" x="160.5" y="239.7">
Generate private random number (PRNI)
</text>
<g transform="translate(857.5, 0) scale(-1, 1)">
<line x1="428.5" x2="470.5" y1="289.41" y2="289.41" class="g"/>
<line x1="470.5" x2="470.5" y1="289.41" y2="302.41" class="g"/>
<line x1="429.5" x2="470.5" y1="302.41" y2="302.41" class="g"/>
<polygon points="439.5 298.41 429.5 302.41 439.5 306.41 435.5 302.41" class="e"/>
</g>
<g transform="translate(-365,0)">
<text font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="287" x="435.5" y="284.34">
Generate public random number (PRNS) = G
</text>
<text font-family="sans-serif" font-size="10" lengthAdjust="spacingAndGlyphs" textLength="25" x="722.5" y="279.05">
PRNI
</text>
<text font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="36" x="747.5" y="284.34">
%PM)
</text>
</g>
<polygon points="47.5 327.41 37.5 331.41 47.5 335.41 43.5 331.41" class="e"/>
<line x1="41.5" x2="427.5" y1="331.41" y2="331.41" class="g"/>
<text font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="77" x="53.5" y="326.47">
sends PRNS
</text>
<line x1="36.5" x2="78.5" y1="363.18" y2="363.18" class="g"/>
<line x1="78.5" x2="78.5" y1="363.18" y2="376.18" class="g"/>
<line x1="37.5" x2="78.5" y1="376.18" y2="376.18" class="g"/>
<polygon points="47.5 372.18 37.5 376.18 47.5 380.18 43.5 376.18" class="e"/>
<text font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="110" x="43.5" y="358.11">
Use Server PRNS
</text>
<text font-family="sans-serif" font-size="10" lengthAdjust="spacingAndGlyphs" textLength="25" x="153.5" y="352.82">
PRNI
</text>
<text font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="234" x="178.5" y="358.11">
%PM to generate shared secret (SS)
</text>
<g transform="translate(857.5, 0) scale(-1, 1)">
<line x1="428.5" x2="470.5" y1="407.82" y2="407.82" class="g"/>
<line x1="470.5" x2="470.5" y1="407.82" y2="420.82" class="g"/>
<line x1="429.5" x2="470.5" y1="420.82" y2="420.82" class="g"/>
<polygon points="439.5 416.82 429.5 420.82 439.5 424.82 435.5 420.82" class="e"/>
</g>
<g transform="translate(-376,0)">
<text font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="104" x="435.5" y="402.75">
Use Client PRNS
</text>
<text font-family="sans-serif" font-size="10" lengthAdjust="spacingAndGlyphs" textLength="25" x="539.5" y="397.46">
PRNI
</text>
<text font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="234" x="564.5" y="402.75">
%PM to generate shared secret (SS)
</text>
</g>
</g>
</svg>
@startuml
participant Client as C
participant Server as S
Title SSH Asymmetric Internals Sequence
== Initial Connection ==
C --> S: Connection establishment request
S --> C: Here are the protocols I support & my public host-key (identifier)
C --> C: Do I support these methods? (If None Supported Fail)
== Diffie-Hellman ==
C <-> S: Agree publicly on `prime modulus`(PM) & `generator`(G)
C --> C: Generate private random number (PRNI)
C --> C: Generate public random number (PRNS) = G<sup>PRNI</sup>%PM)
C --> S: sends PRNS
S --> S: Generate private random number (PRNI)
S --> S: Generate public random number (PRNS) = G<sup>PRNI</sup>%PM)
S --> C: sends PRNS
C --> C: Use Server PRNS<sup>PRNI</sup>%PM to generate shared secret (SS)
S --> S: Use Client PRNS<sup>PRNI</sup>%PM to generate shared secret (SS)
== Authentication (asymmetric key) ==
C --> S: Transmit identity seeking to prove
S --> S: Verify account being accessed contains identity supplied
...If identity Not Found Fail...
S --> S: Generate new private random number (PRNC)
S --> S: Encrypt PRNC (PRNCE) with the public-key found
S --> C: Send Client PRNCE
C --> C: Attempt to decrypt PRNCE using private-key matching sent identity
C --> S: Send Hash of the SS & decrypted PRNCE (VHASH)
S --> S: Generates hash & compares hash to VHASH
...If Not Matching Fail...
@enduml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment