1069 lines
121 KiB
HTML
1069 lines
121 KiB
HTML
<?xml version="1.0" encoding="utf-8" ?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<!-- This file is generated by Nim. -->
|
|
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>src/nimPGP</title>
|
|
|
|
<!-- Favicon -->
|
|
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
|
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
|
|
|
<!-- CSS -->
|
|
<link rel="stylesheet" type="text/css" href="nimdoc.out.css?v=2.0.6">
|
|
|
|
<!-- JS -->
|
|
<script type="text/javascript" src="dochack.js?v=2.0.6"></script>
|
|
</head>
|
|
<body>
|
|
<div class="document" id="documentId">
|
|
<div class="container">
|
|
<h1 class="title">src/nimPGP</h1>
|
|
<div class="row">
|
|
<div class="three columns">
|
|
<div class="theme-select-wrapper">
|
|
<label for="theme-select">Theme: </label>
|
|
<select id="theme-select" onchange="setTheme(this.value)">
|
|
<option value="auto">🌗 Match OS</option>
|
|
<option value="dark">🌑 Dark</option>
|
|
<option value="light">🌕 Light</option>
|
|
</select>
|
|
</div>
|
|
<div id="global-links">
|
|
<ul class="simple">
|
|
<li><a id="indexLink" href="theindex.html">Index</a></li>
|
|
</ul>
|
|
</div>
|
|
<div id="searchInputDiv">
|
|
Search: <input type="search" id="searchInput" onkeyup="search()"/>
|
|
</div>
|
|
<div>
|
|
Group by:
|
|
<select onchange="groupBy(this.value)">
|
|
<option value="section">Section</option>
|
|
<option value="type">Type</option>
|
|
</select>
|
|
</div>
|
|
<ul class="simple simple-toc" id="toc-list">
|
|
<li>
|
|
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
|
|
</li>
|
|
<li>
|
|
<details open>
|
|
<summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
|
|
<ul class="simple simple-toc-section">
|
|
<li><a class="reference" href="#AtomicPasswordHandler" title="AtomicPasswordHandler = object of PasswordHandler">AtomicPasswordHandler</a></li>
|
|
<li><a class="reference" href="#Cert" title="Cert = object
|
|
public*: PublicKey
|
|
private*: PrivateKey
|
|
primaryKeyId*: string
|
|
subkeys*: Table[string, Subkey]">Cert</a></li>
|
|
<li><a class="reference" href="#CertGenerationFailedException" title="CertGenerationFailedException = object of SequoiaException">CertGenerationFailedException</a></li>
|
|
<li><a class="reference" href="#CertHasEncryptedKeyException" title="CertHasEncryptedKeyException = object of SequoiaException">CertHasEncryptedKeyException</a></li>
|
|
<li><a class="reference" href="#CertLacksPrivateKey" title="CertLacksPrivateKey = object of NimSideSequoiaException">CertLacksPrivateKey</a></li>
|
|
<li><a class="reference" href="#CertMaybeRevokedException" title="CertMaybeRevokedException = object of SequoiaException">CertMaybeRevokedException</a></li>
|
|
<li><a class="reference" href="#CertParsingException" title="CertParsingException = object of SequoiaException">CertParsingException</a></li>
|
|
<li><a class="reference" href="#CertRevokedException" title="CertRevokedException = object of SequoiaException">CertRevokedException</a></li>
|
|
<li><a class="reference" href="#Decryption" title="Decryption = object
|
|
successful*: bool
|
|
body*: string">Decryption</a></li>
|
|
<li><a class="reference" href="#ExpectedPrivateKeyGotPublicException" title="ExpectedPrivateKeyGotPublicException = object of MissMatchingKey">ExpectedPrivateKeyGotPublicException</a></li>
|
|
<li><a class="reference" href="#FailedToEncryptKeyException" title="FailedToEncryptKeyException = object of SequoiaException">FailedToEncryptKeyException</a></li>
|
|
<li><a class="reference" href="#FailedToParseKeyException" title="FailedToParseKeyException = object of CertParsingException">FailedToParseKeyException</a></li>
|
|
<li><a class="reference" href="#FailedToParseKeyPrivateException" title="FailedToParseKeyPrivateException = object of CertParsingException">FailedToParseKeyPrivateException</a></li>
|
|
<li><a class="reference" href="#FailedToParseKeyPublicException" title="FailedToParseKeyPublicException = object of CertParsingException">FailedToParseKeyPublicException</a></li>
|
|
<li><a class="reference" href="#FailedToParseMessageException" title="FailedToParseMessageException = object of SequoiaException">FailedToParseMessageException</a></li>
|
|
<li><a class="reference" href="#FailedToReadFromBufferException" title="FailedToReadFromBufferException = object of SequoiaException">FailedToReadFromBufferException</a></li>
|
|
<li><a class="reference" href="#FailedToRevokePrimaryKeyException" title="FailedToRevokePrimaryKeyException = object of SequoiaException">FailedToRevokePrimaryKeyException</a></li>
|
|
<li><a class="reference" href="#FailedToRevokeSubkeyException" title="FailedToRevokeSubkeyException = object of SequoiaException">FailedToRevokeSubkeyException</a></li>
|
|
<li><a class="reference" href="#FailedToWriteMessageException" title="FailedToWriteMessageException = object of SequoiaException">FailedToWriteMessageException</a></li>
|
|
<li><a class="reference" href="#FoundEncryptedSecretButNoPasswordHandlerException" title="FoundEncryptedSecretButNoPasswordHandlerException = object of PasswordException">FoundEncryptedSecretButNoPasswordHandlerException</a></li>
|
|
<li><a class="reference" href="#GlobalPasswordHandler" title="GlobalPasswordHandler = object of PasswordHandler">GlobalPasswordHandler</a></li>
|
|
<li><a class="reference" href="#IncorrectKeyFlagsException" title="IncorrectKeyFlagsException = object of MissMatchingKey">IncorrectKeyFlagsException</a></li>
|
|
<li><a class="reference" href="#IncorrectPasswordForSecretKeyException" title="IncorrectPasswordForSecretKeyException = object of PasswordException">IncorrectPasswordForSecretKeyException</a></li>
|
|
<li><a class="reference" href="#KeyCannotBeUsedForTransportAndSigningException" title="KeyCannotBeUsedForTransportAndSigningException = object of CertGenerationFailedException">KeyCannotBeUsedForTransportAndSigningException</a></li>
|
|
<li><a class="reference" href="#MissMatchingKey" title="MissMatchingKey = object of SequoiaException">MissMatchingKey</a></li>
|
|
<li><a class="reference" href="#MustBeLiveForMoreThan100SecondsException" title="MustBeLiveForMoreThan100SecondsException = object of NimSideSequoiaException">MustBeLiveForMoreThan100SecondsException</a></li>
|
|
<li><a class="reference" href="#NimSideSequoiaException" title="NimSideSequoiaException = object of SequoiaException">NimSideSequoiaException</a></li>
|
|
<li><a class="reference" href="#NoKeyMeetsSelectionException" title="NoKeyMeetsSelectionException = object of SequoiaException">NoKeyMeetsSelectionException</a></li>
|
|
<li><a class="reference" href="#PackedParserFailedToRecurseException" title="PackedParserFailedToRecurseException = object of SequoiaException">PackedParserFailedToRecurseException</a></li>
|
|
<li><a class="reference" href="#PasswordException" title="PasswordException = object of SequoiaException">PasswordException</a></li>
|
|
<li><a class="reference" href="#PasswordHandler" title="PasswordHandler = object of RootObj">PasswordHandler</a></li>
|
|
<li><a class="reference" href="#PasswordSetToAtomicButMissingEncryptedKeyidException" title="PasswordSetToAtomicButMissingEncryptedKeyidException = object of PasswordException">PasswordSetToAtomicButMissingEncryptedKeyidException</a></li>
|
|
<li><a class="reference" href="#PrivateKey" title="PrivateKey = string">PrivateKey</a></li>
|
|
<li><a class="reference" href="#PublicKey" title="PublicKey = string">PublicKey</a></li>
|
|
<li><a class="reference" href="#SequoiaException" title="SequoiaException = object of CatchableError">SequoiaException</a></li>
|
|
<li><a class="reference" href="#Subkey" title="Subkey = object
|
|
keyFlags*: set[KeyTypes]
|
|
keyId*: string
|
|
expires*: bool
|
|
validLengthSeconds*: uint64
|
|
creationTime*: uint64">Subkey</a></li>
|
|
<li><a class="reference" href="#UninitiatedSubkey" title="UninitiatedSubkey = object
|
|
cipher*: CryptSuites = Cv25519
|
|
keyFlags*: set[KeyTypes]
|
|
keyId*: string
|
|
expires*: bool
|
|
validLengthSeconds*: uint64">UninitiatedSubkey</a></li>
|
|
<li><a class="reference" href="#Verification" title="Verification = object
|
|
isValid*: bool
|
|
body*: string">Verification</a></li>
|
|
|
|
</ul>
|
|
</details>
|
|
</li>
|
|
<li>
|
|
<details open>
|
|
<summary><a class="reference reference-toplevel" href="#10" id="60">Consts</a></summary>
|
|
<ul class="simple simple-toc-section">
|
|
<li><a class="reference" href="#version" title="version = "1.0.3"">version</a></li>
|
|
|
|
</ul>
|
|
</details>
|
|
</li>
|
|
<li>
|
|
<details open>
|
|
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
|
|
<ul class="simple simple-toc-section">
|
|
<ul class="simple nested-toc-section">convertGlobalPasswordToAtomic
|
|
<li><a class="reference" href="#convertGlobalPasswordToAtomic%2CCert%2CGlobalPasswordHandler" title="convertGlobalPasswordToAtomic(a: Cert; b: GlobalPasswordHandler): AtomicPasswordHandler">convertGlobalPasswordToAtomic(a: Cert; b: GlobalPasswordHandler): AtomicPasswordHandler</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">decryptMessage
|
|
<li><a class="reference" href="#decryptMessage%2C%2Cstring" title="decryptMessage(privateKeys: openArray[PrivateKey] or PrivateKey or
|
|
seq[PrivateKey]; message: string; passwordHandler = AtomicPasswordHandler()): Decryption">decryptMessage(privateKeys: openArray[PrivateKey] or PrivateKey or
|
|
seq[PrivateKey]; message: string; passwordHandler = AtomicPasswordHandler()): Decryption</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">encryptKeys
|
|
<li><a class="reference" href="#encryptKeys%2CCert%2CPasswordHandler" title="encryptKeys(a: Cert; newPassword: PasswordHandler;
|
|
oldPassword = PasswordHandler()): Cert">encryptKeys(a: Cert; newPassword: PasswordHandler;
|
|
oldPassword = PasswordHandler()): Cert</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">getRecipients
|
|
<li><a class="reference" href="#getRecipients%2Cstring" title="getRecipients(message: string): seq[string]">getRecipients(message: string): seq[string]</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">isPrimaryKeyRevoked
|
|
<li><a class="reference" href="#isPrimaryKeyRevoked%2CPublicKey" title="isPrimaryKeyRevoked(key: PublicKey): RevocationStatus">isPrimaryKeyRevoked(key: PublicKey): RevocationStatus</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">isSubkeyRevoked
|
|
<li><a class="reference" href="#isSubkeyRevoked%2CPublicKey%2C" title="isSubkeyRevoked(key: PublicKey; keyid: string or Subkey): RevocationStatus">isSubkeyRevoked(key: PublicKey; keyid: string or Subkey): RevocationStatus</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">newCert
|
|
<li><a class="reference" href="#newCert%2C%2CCryptSuites%2Cseq%5Bstring%5D" title="newCert(subkeySeq: seq[UninitiatedSubkey] | openArray[UninitiatedSubkey];
|
|
primaryCipher: CryptSuites = Cv25519; user_ids: seq[string] = @[];
|
|
validLength: uint32 | Duration = uint32 0): Cert">newCert(subkeySeq: seq[UninitiatedSubkey] | openArray[UninitiatedSubkey];
|
|
primaryCipher: CryptSuites = Cv25519; user_ids: seq[string] = @[];
|
|
validLength: uint32 | Duration = uint32 0): Cert</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">newPasswordHandler
|
|
<li><a class="reference" href="#newPasswordHandler%2Cstring" title="newPasswordHandler(globalPassword: string): GlobalPasswordHandler">newPasswordHandler(globalPassword: string): GlobalPasswordHandler</a></li>
|
|
<li><a class="reference" href="#newPasswordHandler%2CTable%5Bstring%2Cstring%5D" title="newPasswordHandler(keyidToPassword: Table[string, string]): AtomicPasswordHandler">newPasswordHandler(keyidToPassword: Table[string, string]): AtomicPasswordHandler</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">newPasswordHandlerKeyring
|
|
<li><a class="reference" href="#newPasswordHandlerKeyring%2Cvarargs%5BAtomicPasswordHandler%5D" title="newPasswordHandlerKeyring(handlers: varargs[AtomicPasswordHandler]): AtomicPasswordHandler">newPasswordHandlerKeyring(handlers: varargs[AtomicPasswordHandler]): AtomicPasswordHandler</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">newSubkey
|
|
<li><a class="reference" href="#newSubkey%2Cset%5BKeyTypes%5D%2CCryptSuites" title="newSubkey(keyFlags: set[KeyTypes]; cipher: CryptSuites = Cv25519;
|
|
validLength: uint32 or Duration = uint32 0): UninitiatedSubkey">newSubkey(keyFlags: set[KeyTypes]; cipher: CryptSuites = Cv25519;
|
|
validLength: uint32 or Duration = uint32 0): UninitiatedSubkey</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">revokePrimaryKey
|
|
<li><a class="reference" href="#revokePrimaryKey%2CCert%2CReasonForRevocation%2Cstring" title="revokePrimaryKey(cert: Cert; reason: ReasonForRevocation = Unspecified;
|
|
message: string = ""; passwordHandler = PasswordHandler()): Cert">revokePrimaryKey(cert: Cert; reason: ReasonForRevocation = Unspecified;
|
|
message: string = ""; passwordHandler = PasswordHandler()): Cert</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">revokeSubkey
|
|
<li><a class="reference" href="#revokeSubkey%2CCert%2Cstring%2CReasonForRevocation%2Cstring" title="revokeSubkey(cert: Cert; subkey_keyid: string;
|
|
reason: ReasonForRevocation = Unspecified; message: string = "";
|
|
passwordHandler = PasswordHandler()): Cert">revokeSubkey(cert: Cert; subkey_keyid: string;
|
|
reason: ReasonForRevocation = Unspecified; message: string = "";
|
|
passwordHandler = PasswordHandler()): Cert</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">scaffoldKey
|
|
<li><a class="reference" href="#scaffoldKey" title="scaffoldKey(key: PublicKey or PrivateKey): Cert">scaffoldKey(key: PublicKey or PrivateKey): Cert</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">sendMessage
|
|
<li><a class="reference" href="#sendMessage%2C%2Cstring" title="sendMessage(publicKeys: openArray[PublicKey] or PublicKey or seq[PublicKey];
|
|
message: string): string">sendMessage(publicKeys: openArray[PublicKey] or PublicKey or seq[PublicKey];
|
|
message: string): string</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">signMessage
|
|
<li><a class="reference" href="#signMessage%2CPrivateKey%2Cstring%2Cstring" title="signMessage(privateKey: PrivateKey; message: string;
|
|
keyid: string or Subkey = ""; passwordHandler = PasswordHandler()): string">signMessage(privateKey: PrivateKey; message: string;
|
|
keyid: string or Subkey = ""; passwordHandler = PasswordHandler()): string</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">verifySignature
|
|
<li><a class="reference" href="#verifySignature%2C%2Cstring" title="verifySignature(publicKeys: openArray[PublicKey] or PublicKey or seq[string];
|
|
message: string): Verification">verifySignature(publicKeys: openArray[PublicKey] or PublicKey or seq[string];
|
|
message: string): Verification</a></li>
|
|
|
|
</ul>
|
|
|
|
</ul>
|
|
</details>
|
|
</li>
|
|
<li>
|
|
<a class="reference reference-toplevel" href="#19" id="69">Exports</a>
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
<div class="nine columns" id="content">
|
|
|
|
<div id="tocRoot"></div>
|
|
|
|
<p class="module-desc"></p>
|
|
<div class="section" id="6">
|
|
<h1><a class="toc-backref" href="#6">Imports</a></h1>
|
|
<dl class="item">
|
|
<a class="reference external" href="binding.html">binding</a>
|
|
</dl>
|
|
</div>
|
|
<div class="section" id="7">
|
|
<h1><a class="toc-backref" href="#7">Types</a></h1>
|
|
<dl class="item">
|
|
<div id="AtomicPasswordHandler">
|
|
<dt><pre><a href="nimPGP.html#AtomicPasswordHandler"><span class="Identifier">AtomicPasswordHandler</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#PasswordHandler"><span class="Identifier">PasswordHandler</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="Cert">
|
|
<dt><pre><a href="nimPGP.html#Cert"><span class="Identifier">Cert</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
|
|
<span class="Identifier">public</span><span class="Operator">*</span><span class="Other">:</span> <a href="nimPGP.html#PublicKey"><span class="Identifier">PublicKey</span></a>
|
|
<span class="Identifier">private</span><span class="Operator">*</span><span class="Other">:</span> <a href="nimPGP.html#PrivateKey"><span class="Identifier">PrivateKey</span></a>
|
|
<span class="Identifier">primaryKeyId</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span>
|
|
<span class="Identifier">subkeys</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">Table</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">,</span> <a href="nimPGP.html#Subkey"><span class="Identifier">Subkey</span></a><span class="Other">]</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="CertGenerationFailedException">
|
|
<dt><pre><a href="nimPGP.html#CertGenerationFailedException"><span class="Identifier">CertGenerationFailedException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#SequoiaException"><span class="Identifier">SequoiaException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="CertHasEncryptedKeyException">
|
|
<dt><pre><a href="nimPGP.html#CertHasEncryptedKeyException"><span class="Identifier">CertHasEncryptedKeyException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#SequoiaException"><span class="Identifier">SequoiaException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="CertLacksPrivateKey">
|
|
<dt><pre><a href="nimPGP.html#CertLacksPrivateKey"><span class="Identifier">CertLacksPrivateKey</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#NimSideSequoiaException"><span class="Identifier">NimSideSequoiaException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="CertMaybeRevokedException">
|
|
<dt><pre><a href="nimPGP.html#CertMaybeRevokedException"><span class="Identifier">CertMaybeRevokedException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#SequoiaException"><span class="Identifier">SequoiaException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="CertParsingException">
|
|
<dt><pre><a href="nimPGP.html#CertParsingException"><span class="Identifier">CertParsingException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#SequoiaException"><span class="Identifier">SequoiaException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="CertRevokedException">
|
|
<dt><pre><a href="nimPGP.html#CertRevokedException"><span class="Identifier">CertRevokedException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#SequoiaException"><span class="Identifier">SequoiaException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="Decryption">
|
|
<dt><pre><a href="nimPGP.html#Decryption"><span class="Identifier">Decryption</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
|
|
<span class="Identifier">successful</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">bool</span>
|
|
<span class="Identifier">body</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="ExpectedPrivateKeyGotPublicException">
|
|
<dt><pre><a href="nimPGP.html#ExpectedPrivateKeyGotPublicException"><span class="Identifier">ExpectedPrivateKeyGotPublicException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#MissMatchingKey"><span class="Identifier">MissMatchingKey</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="FailedToEncryptKeyException">
|
|
<dt><pre><a href="nimPGP.html#FailedToEncryptKeyException"><span class="Identifier">FailedToEncryptKeyException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#SequoiaException"><span class="Identifier">SequoiaException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="FailedToParseKeyException">
|
|
<dt><pre><a href="nimPGP.html#FailedToParseKeyException"><span class="Identifier">FailedToParseKeyException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#CertParsingException"><span class="Identifier">CertParsingException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="FailedToParseKeyPrivateException">
|
|
<dt><pre><a href="nimPGP.html#FailedToParseKeyPrivateException"><span class="Identifier">FailedToParseKeyPrivateException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#CertParsingException"><span class="Identifier">CertParsingException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="FailedToParseKeyPublicException">
|
|
<dt><pre><a href="nimPGP.html#FailedToParseKeyPublicException"><span class="Identifier">FailedToParseKeyPublicException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#CertParsingException"><span class="Identifier">CertParsingException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="FailedToParseMessageException">
|
|
<dt><pre><a href="nimPGP.html#FailedToParseMessageException"><span class="Identifier">FailedToParseMessageException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#SequoiaException"><span class="Identifier">SequoiaException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="FailedToReadFromBufferException">
|
|
<dt><pre><a href="nimPGP.html#FailedToReadFromBufferException"><span class="Identifier">FailedToReadFromBufferException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#SequoiaException"><span class="Identifier">SequoiaException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="FailedToRevokePrimaryKeyException">
|
|
<dt><pre><a href="nimPGP.html#FailedToRevokePrimaryKeyException"><span class="Identifier">FailedToRevokePrimaryKeyException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#SequoiaException"><span class="Identifier">SequoiaException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="FailedToRevokeSubkeyException">
|
|
<dt><pre><a href="nimPGP.html#FailedToRevokeSubkeyException"><span class="Identifier">FailedToRevokeSubkeyException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#SequoiaException"><span class="Identifier">SequoiaException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="FailedToWriteMessageException">
|
|
<dt><pre><a href="nimPGP.html#FailedToWriteMessageException"><span class="Identifier">FailedToWriteMessageException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#SequoiaException"><span class="Identifier">SequoiaException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="FoundEncryptedSecretButNoPasswordHandlerException">
|
|
<dt><pre><a href="nimPGP.html#FoundEncryptedSecretButNoPasswordHandlerException"><span class="Identifier">FoundEncryptedSecretButNoPasswordHandlerException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#PasswordException"><span class="Identifier">PasswordException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="GlobalPasswordHandler">
|
|
<dt><pre><a href="nimPGP.html#GlobalPasswordHandler"><span class="Identifier">GlobalPasswordHandler</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#PasswordHandler"><span class="Identifier">PasswordHandler</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="IncorrectKeyFlagsException">
|
|
<dt><pre><a href="nimPGP.html#IncorrectKeyFlagsException"><span class="Identifier">IncorrectKeyFlagsException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#MissMatchingKey"><span class="Identifier">MissMatchingKey</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="IncorrectPasswordForSecretKeyException">
|
|
<dt><pre><a href="nimPGP.html#IncorrectPasswordForSecretKeyException"><span class="Identifier">IncorrectPasswordForSecretKeyException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#PasswordException"><span class="Identifier">PasswordException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="KeyCannotBeUsedForTransportAndSigningException">
|
|
<dt><pre><a href="nimPGP.html#KeyCannotBeUsedForTransportAndSigningException"><span class="Identifier">KeyCannotBeUsedForTransportAndSigningException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#CertGenerationFailedException"><span class="Identifier">CertGenerationFailedException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="MissMatchingKey">
|
|
<dt><pre><a href="nimPGP.html#MissMatchingKey"><span class="Identifier">MissMatchingKey</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#SequoiaException"><span class="Identifier">SequoiaException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="MustBeLiveForMoreThan100SecondsException">
|
|
<dt><pre><a href="nimPGP.html#MustBeLiveForMoreThan100SecondsException"><span class="Identifier">MustBeLiveForMoreThan100SecondsException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#NimSideSequoiaException"><span class="Identifier">NimSideSequoiaException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="NimSideSequoiaException">
|
|
<dt><pre><a href="nimPGP.html#NimSideSequoiaException"><span class="Identifier">NimSideSequoiaException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#SequoiaException"><span class="Identifier">SequoiaException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="NoKeyMeetsSelectionException">
|
|
<dt><pre><a href="nimPGP.html#NoKeyMeetsSelectionException"><span class="Identifier">NoKeyMeetsSelectionException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#SequoiaException"><span class="Identifier">SequoiaException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="PackedParserFailedToRecurseException">
|
|
<dt><pre><a href="nimPGP.html#PackedParserFailedToRecurseException"><span class="Identifier">PackedParserFailedToRecurseException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#SequoiaException"><span class="Identifier">SequoiaException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="PasswordException">
|
|
<dt><pre><a href="nimPGP.html#PasswordException"><span class="Identifier">PasswordException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#SequoiaException"><span class="Identifier">SequoiaException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="PasswordHandler">
|
|
<dt><pre><a href="nimPGP.html#PasswordHandler"><span class="Identifier">PasswordHandler</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <span class="Identifier">RootObj</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="PasswordSetToAtomicButMissingEncryptedKeyidException">
|
|
<dt><pre><a href="nimPGP.html#PasswordSetToAtomicButMissingEncryptedKeyidException"><span class="Identifier">PasswordSetToAtomicButMissingEncryptedKeyidException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="nimPGP.html#PasswordException"><span class="Identifier">PasswordException</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="PrivateKey">
|
|
<dt><pre><a href="nimPGP.html#PrivateKey"><span class="Identifier">PrivateKey</span></a> <span class="Other">=</span> <span class="Identifier">string</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="PublicKey">
|
|
<dt><pre><a href="nimPGP.html#PublicKey"><span class="Identifier">PublicKey</span></a> <span class="Other">=</span> <span class="Identifier">string</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="SequoiaException">
|
|
<dt><pre><a href="nimPGP.html#SequoiaException"><span class="Identifier">SequoiaException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <span class="Identifier">CatchableError</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="Subkey">
|
|
<dt><pre><a href="nimPGP.html#Subkey"><span class="Identifier">Subkey</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
|
|
<span class="Identifier">keyFlags</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">set</span><span class="Other">[</span><a href="binding.html#KeyTypes"><span class="Identifier">KeyTypes</span></a><span class="Other">]</span>
|
|
<span class="Identifier">keyId</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span>
|
|
<span class="Identifier">expires</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">bool</span>
|
|
<span class="Identifier">validLengthSeconds</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">uint64</span>
|
|
<span class="Identifier">creationTime</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">uint64</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="UninitiatedSubkey">
|
|
<dt><pre><a href="nimPGP.html#UninitiatedSubkey"><span class="Identifier">UninitiatedSubkey</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
|
|
<span class="Identifier">cipher</span><span class="Operator">*</span><span class="Other">:</span> <a href="binding.html#CryptSuites"><span class="Identifier">CryptSuites</span></a> <span class="Other">=</span> <span class="DecNumber">Cv25519</span>
|
|
<span class="Identifier">keyFlags</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">set</span><span class="Other">[</span><a href="binding.html#KeyTypes"><span class="Identifier">KeyTypes</span></a><span class="Other">]</span>
|
|
<span class="Identifier">keyId</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span>
|
|
<span class="Identifier">expires</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">bool</span>
|
|
<span class="Identifier">validLengthSeconds</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">uint64</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="Verification">
|
|
<dt><pre><a href="nimPGP.html#Verification"><span class="Identifier">Verification</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
|
|
<span class="Identifier">isValid</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">bool</span>
|
|
<span class="Identifier">body</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</dl>
|
|
</div>
|
|
<div class="section" id="10">
|
|
<h1><a class="toc-backref" href="#10">Consts</a></h1>
|
|
<dl class="item">
|
|
<div id="version">
|
|
<dt><pre><a href="nimPGP.html#version"><span class="Identifier">version</span></a> <span class="Other">=</span> <span class="StringLit">"1.0.3"</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</dl>
|
|
</div>
|
|
<div class="section" id="12">
|
|
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
|
<dl class="item">
|
|
<div id="convertGlobalPasswordToAtomic-procs-all">
|
|
<div id="convertGlobalPasswordToAtomic,Cert,GlobalPasswordHandler">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#convertGlobalPasswordToAtomic%2CCert%2CGlobalPasswordHandler"><span class="Identifier">convertGlobalPasswordToAtomic</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="nimPGP.html#Cert"><span class="Identifier">Cert</span></a><span class="Other">;</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="nimPGP.html#GlobalPasswordHandler"><span class="Identifier">GlobalPasswordHandler</span></a><span class="Other">)</span><span class="Other">:</span> <a href="nimPGP.html#AtomicPasswordHandler"><span class="Identifier">AtomicPasswordHandler</span></a> {.
|
|
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
This is usually used in the context of creating a keyring with <a class="reference internal nimdoc" title="proc newPasswordHandlerKeyring(handlers: varargs[AtomicPasswordHandler]): AtomicPasswordHandler" href="#newPasswordHandlerKeyring,varargs[AtomicPasswordHandler]">newPasswordHandlerKeyring</a>... This design allows you to both have simple to make global keys, and make them work in key rights simply. Its needed because otherwise the handler has no way of knowing what keys map to what.
|
|
<p><strong class="examples_text">Example:</strong></p>
|
|
<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">sequtils</span>
|
|
<span class="Keyword">import</span> <span class="Identifier">sugar</span>
|
|
<span class="Keyword">import</span> <span class="Identifier">nimPGP</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">signingKey</span> <span class="Operator">=</span> <span class="Identifier">newSubkey</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="Identifier">ForSigning</span><span class="Punctuation">}</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">transportKey</span> <span class="Operator">=</span> <span class="Identifier">newSubkey</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="Identifier">ForTransport</span><span class="Punctuation">}</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">certOne</span> <span class="Operator">=</span> <span class="Identifier">newCert</span><span class="Punctuation">(</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="Identifier">signingKey</span><span class="Punctuation">,</span> <span class="Identifier">transportKey</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">certTwo</span> <span class="Operator">=</span> <span class="Identifier">newCert</span><span class="Punctuation">(</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="Identifier">signingKey</span><span class="Punctuation">,</span> <span class="Identifier">transportKey</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
|
|
|
<span class="Comment">#Creates a handler that can be now used with [newPasswordHandlerKeyring]</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">handlerOne</span> <span class="Operator">=</span> <span class="Identifier">convertGlobalPasswordToAtomic</span><span class="Punctuation">(</span><span class="Identifier">certOne</span><span class="Punctuation">,</span> <span class="Identifier">newPasswordHandler</span><span class="Punctuation">(</span><span class="StringLit">"hellofutureme"</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">handlerTwo</span> <span class="Operator">=</span> <span class="Identifier">convertGlobalPasswordToAtomic</span><span class="Punctuation">(</span><span class="Identifier">certTwo</span><span class="Punctuation">,</span> <span class="Identifier">newPasswordHandler</span><span class="Punctuation">(</span><span class="StringLit">"hellopastme"</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
|
|
|
<span class="Keyword">let</span> <span class="Identifier">encryptedCertOne</span> <span class="Operator">=</span> <span class="Identifier">encryptKeys</span><span class="Punctuation">(</span><span class="Identifier">certOne</span><span class="Punctuation">,</span> <span class="Identifier">handlerOne</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">encryptedCertTwo</span> <span class="Operator">=</span> <span class="Identifier">encryptKeys</span><span class="Punctuation">(</span><span class="Identifier">certTwo</span><span class="Punctuation">,</span> <span class="Identifier">handlerTwo</span><span class="Punctuation">)</span>
|
|
|
|
<span class="Keyword">let</span> <span class="Identifier">encryptedMessage</span> <span class="Operator">=</span> <span class="Identifier">sendMessage</span><span class="Punctuation">(</span><span class="Identifier">encryptedCertTwo</span><span class="Operator">.</span><span class="Identifier">public</span><span class="Punctuation">,</span> <span class="StringLit">"hello!"</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">keyring</span> <span class="Operator">=</span> <span class="Identifier">newPasswordHandlerKeyring</span><span class="Punctuation">(</span><span class="Identifier">handlerOne</span><span class="Punctuation">,</span> <span class="Identifier">handlerTwo</span><span class="Punctuation">)</span>
|
|
|
|
<span class="Keyword">let</span> <span class="Identifier">keys</span> <span class="Operator">=</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="Identifier">encryptedCertOne</span><span class="Punctuation">,</span> <span class="Identifier">encryptedCertTwo</span><span class="Punctuation">]</span><span class="Operator">.</span><span class="Identifier">map</span><span class="Punctuation">(</span><span class="Identifier">x</span> <span class="Operator">=></span> <span class="Identifier">x</span><span class="Operator">.</span><span class="Identifier">private</span><span class="Punctuation">)</span>
|
|
|
|
<span class="Keyword">let</span> <span class="Identifier">unencryptedMessage</span> <span class="Operator">=</span> <span class="Identifier">decryptMessage</span><span class="Punctuation">(</span><span class="Identifier">keys</span><span class="Punctuation">,</span> <span class="Identifier">encryptedMessage</span><span class="Punctuation">,</span> <span class="Identifier">keyring</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">doAssert</span> <span class="Identifier">unencryptedMessage</span><span class="Operator">.</span><span class="Identifier">body</span> <span class="Operator">==</span> <span class="StringLit">"hello!"</span></pre>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
<div id="decryptMessage-procs-all">
|
|
<div id="decryptMessage,,string">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#decryptMessage%2C%2Cstring"><span class="Identifier">decryptMessage</span></a><span class="Other">(</span><span class="Identifier">privateKeys</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><a href="nimPGP.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">]</span> <span class="Keyword">or</span> <a href="nimPGP.html#PrivateKey"><span class="Identifier">PrivateKey</span></a> <span class="Keyword">or</span>
|
|
<span class="Identifier">seq</span><span class="Other">[</span><a href="nimPGP.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">message</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">passwordHandler</span> <span class="Other">=</span> <a href="nimPGP.html#AtomicPasswordHandler"><span class="Identifier">AtomicPasswordHandler</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">)</span><span class="Other">:</span> <a href="nimPGP.html#Decryption"><span class="Identifier">Decryption</span></a></pre></dt>
|
|
<dd>
|
|
|
|
<p>For the inverse procedure, see <a class="reference internal nimdoc" title="proc sendMessage(publicKeys: openArray[PublicKey] or PublicKey or seq[PublicKey];
|
|
message: string): string" href="#sendMessage,,string">sendMessage</a></p>
|
|
<p>Can take in multiple private keys, but you must create a password keyring using <a class="reference internal nimdoc" title="proc newPasswordHandlerKeyring(handlers: varargs[AtomicPasswordHandler]): AtomicPasswordHandler" href="#newPasswordHandlerKeyring,varargs[AtomicPasswordHandler]">newPasswordHandlerKeyring</a></p>
|
|
<hr />
|
|
<p>Capable of raising the following exceptions:</p>
|
|
<p><a class="reference internal nimdoc" title="object FailedToParseKeyPrivateException" href="#FailedToParseKeyPrivateException">FailedToParseKeyPrivateException</a>, <a class="reference internal nimdoc" title="object CertRevokedException" href="#CertRevokedException">CertRevokedException</a>, <a class="reference internal nimdoc" title="object NoKeyMeetsSelectionException" href="#NoKeyMeetsSelectionException">NoKeyMeetsSelectionException</a></p>
|
|
<p><a class="reference internal nimdoc" title="object ExpectedPrivateKeyGotPublicException" href="#ExpectedPrivateKeyGotPublicException">ExpectedPrivateKeyGotPublicException</a>, <a class="reference internal" href="#CertIsInvalidException">CertIsInvalidException</a></p>
|
|
<p><a class="reference internal nimdoc" title="object FailedToParseMessageException" href="#FailedToParseMessageException">FailedToParseMessageException</a>, <a class="reference internal nimdoc" title="object FailedToReadFromBufferException" href="#FailedToReadFromBufferException">FailedToReadFromBufferException</a>, <a class="reference internal nimdoc" title="object PackedParserFailedToRecurseException" href="#PackedParserFailedToRecurseException">PackedParserFailedToRecurseException</a></p>
|
|
<p><a class="reference internal nimdoc" title="object IncorrectPasswordForSecretKeyException" href="#IncorrectPasswordForSecretKeyException">IncorrectPasswordForSecretKeyException</a>, <a class="reference internal nimdoc" title="object FoundEncryptedSecretButNoPasswordHandlerException" href="#FoundEncryptedSecretButNoPasswordHandlerException">FoundEncryptedSecretButNoPasswordHandlerException</a>, <a class="reference internal nimdoc" title="object PasswordSetToAtomicButMissingEncryptedKeyidException" href="#PasswordSetToAtomicButMissingEncryptedKeyidException">PasswordSetToAtomicButMissingEncryptedKeyidException</a></p>
|
|
|
|
<p><strong class="examples_text">Example:</strong></p>
|
|
<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">nimPGP</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">cert</span> <span class="Operator">=</span> <span class="Identifier">newCert</span><span class="Punctuation">(</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="Identifier">newSubkey</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="Identifier">ForTransport</span><span class="Punctuation">}</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">newSubkey</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="Identifier">ForSigning</span><span class="Punctuation">}</span><span class="Punctuation">)</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">signedMessage</span> <span class="Operator">=</span> <span class="Identifier">signMessage</span><span class="Punctuation">(</span><span class="Identifier">cert</span><span class="Operator">.</span><span class="Identifier">private</span><span class="Punctuation">,</span> <span class="StringLit">"Confidential Information"</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">encrypted</span> <span class="Operator">=</span> <span class="Identifier">sendMessage</span><span class="Punctuation">(</span><span class="Identifier">cert</span><span class="Operator">.</span><span class="Identifier">public</span><span class="Punctuation">,</span> <span class="Identifier">signedMessage</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">decrypted</span> <span class="Operator">=</span> <span class="Identifier">decryptMessage</span><span class="Punctuation">(</span><span class="Identifier">cert</span><span class="Operator">.</span><span class="Identifier">private</span><span class="Punctuation">,</span> <span class="Identifier">encrypted</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">doAssert</span> <span class="Identifier">decrypted</span><span class="Operator">.</span><span class="Identifier">successful</span>
|
|
<span class="Identifier">echo</span> <span class="Identifier">verifySignature</span><span class="Punctuation">(</span><span class="Identifier">cert</span><span class="Operator">.</span><span class="Identifier">public</span><span class="Punctuation">,</span> <span class="Identifier">decrypted</span><span class="Operator">.</span><span class="Identifier">body</span><span class="Punctuation">)</span></pre>With Keyring
|
|
<p><strong class="examples_text">Example:</strong></p>
|
|
<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">nimPGP</span>
|
|
<span class="Keyword">import</span> <span class="Identifier">sequtils</span>
|
|
<span class="Keyword">import</span> <span class="Identifier">sugar</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">pwArray</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="Identifier">newPasswordHandler</span><span class="Punctuation">(</span><span class="StringLit">"two"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">newPasswordHandler</span><span class="Punctuation">(</span><span class="StringLit">"one"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">newPasswordHandler</span><span class="Punctuation">(</span><span class="StringLit">"three"</span><span class="Punctuation">)</span><span class="Punctuation">]</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">subkey</span> <span class="Operator">=</span> <span class="Identifier">newSubkey</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="Identifier">ForTransport</span><span class="Punctuation">}</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">certs</span> <span class="Operator">=</span> <span class="Identifier">collect</span><span class="Punctuation">(</span><span class="Keyword">for</span> <span class="Identifier">x</span> <span class="Keyword">in</span> <span class="DecNumber">0</span> <span class="Operator">..</span> <span class="DecNumber">2</span><span class="Punctuation">:</span> <span class="Identifier">encryptKeys</span><span class="Punctuation">(</span><span class="Identifier">newCert</span><span class="Punctuation">(</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="Identifier">subkey</span><span class="Punctuation">]</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">pwArray</span><span class="Punctuation">[</span><span class="Identifier">x</span><span class="Punctuation">]</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
|
<span class="Comment"># They **need** to be atomic handlers in order to know which keys</span>
|
|
<span class="Comment"># are used for </span>
|
|
<span class="Keyword">let</span> <span class="Identifier">atomicPws</span> <span class="Operator">=</span> <span class="Identifier">collect</span><span class="Punctuation">(</span><span class="Keyword">for</span> <span class="Identifier">x</span> <span class="Keyword">in</span> <span class="DecNumber">0</span> <span class="Operator">..</span> <span class="DecNumber">2</span><span class="Punctuation">:</span> <span class="Identifier">convertGlobalPasswordToAtomic</span><span class="Punctuation">(</span><span class="Identifier">certs</span><span class="Punctuation">[</span><span class="Identifier">x</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="Identifier">pwArray</span><span class="Punctuation">[</span><span class="Identifier">x</span><span class="Punctuation">]</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">messages</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="Identifier">certs</span><span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">]</span><span class="Operator">.</span><span class="Identifier">public</span><span class="Operator">.</span><span class="Identifier">sendMessage</span><span class="Punctuation">(</span><span class="StringLit">"0"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">certs</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">]</span><span class="Operator">.</span><span class="Identifier">public</span><span class="Operator">.</span><span class="Identifier">sendMessage</span><span class="Punctuation">(</span><span class="StringLit">"1"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">certs</span><span class="Punctuation">[</span><span class="DecNumber">2</span><span class="Punctuation">]</span><span class="Operator">.</span><span class="Identifier">public</span><span class="Operator">.</span><span class="Identifier">sendMessage</span><span class="Punctuation">(</span><span class="StringLit">"2"</span><span class="Punctuation">)</span><span class="Punctuation">]</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">macroHandler</span> <span class="Operator">=</span> <span class="Identifier">newPasswordHandlerKeyring</span><span class="Punctuation">(</span><span class="Identifier">atomicPws</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">for</span> <span class="Identifier">x</span> <span class="Keyword">in</span> <span class="DecNumber">0</span> <span class="Operator">..</span> <span class="Identifier">messages</span><span class="Operator">.</span><span class="Identifier">high</span><span class="Punctuation">:</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">decrypted</span> <span class="Operator">=</span> <span class="Identifier">decryptMessage</span><span class="Punctuation">(</span><span class="Identifier">certs</span><span class="Operator">.</span><span class="Identifier">map</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Operator">=></span><span class="Identifier">x</span><span class="Operator">.</span><span class="Identifier">private</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">messages</span><span class="Punctuation">[</span><span class="Identifier">x</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="Identifier">macroHandler</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">doASsert</span> <span class="Identifier">decrypted</span><span class="Operator">.</span><span class="Identifier">successful</span> <span class="Operator">==</span> <span class="Identifier">true</span></pre>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
<div id="encryptKeys-procs-all">
|
|
<div id="encryptKeys,Cert,PasswordHandler">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#encryptKeys%2CCert%2CPasswordHandler"><span class="Identifier">encryptKeys</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="nimPGP.html#Cert"><span class="Identifier">Cert</span></a><span class="Other">;</span> <span class="Identifier">newPassword</span><span class="Other">:</span> <a href="nimPGP.html#PasswordHandler"><span class="Identifier">PasswordHandler</span></a><span class="Other">;</span>
|
|
<span class="Identifier">oldPassword</span> <span class="Other">=</span> <a href="nimPGP.html#PasswordHandler"><span class="Identifier">PasswordHandler</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">)</span><span class="Other">:</span> <a href="nimPGP.html#Cert"><span class="Identifier">Cert</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span>
|
|
<span class="Identifier">FailedToWriteMessageException</span><span class="Other">,</span> <span class="Identifier">ExpectedPrivateKeyGotPublicException</span><span class="Other">,</span>
|
|
<span class="Identifier">FailedToParseKeyPublicException</span><span class="Other">,</span> <span class="Identifier">FailedToParseKeyPrivateException</span><span class="Other">,</span>
|
|
<span class="Identifier">NoKeyMeetsSelectionException</span><span class="Other">,</span> <span class="Identifier">FailedToParseMessageException</span><span class="Other">,</span>
|
|
<span class="Identifier">PackedParserFailedToRecurseException</span><span class="Other">,</span> <span class="Identifier">FailedToReadFromBufferException</span><span class="Other">,</span>
|
|
<span class="Identifier">CertGenerationFailedException</span><span class="Other">,</span> <span class="Identifier">FailedToParseKeyException</span><span class="Other">,</span>
|
|
<span class="Identifier">CertRevokedException</span><span class="Other">,</span> <span class="Identifier">FailedToRevokeSubkeyException</span><span class="Other">,</span>
|
|
<span class="Identifier">FailedToRevokePrimaryKeyException</span><span class="Other">,</span> <span class="Identifier">FailedToEncryptKeyException</span><span class="Other">,</span>
|
|
<span class="Identifier">CertMaybeRevokedException</span><span class="Other">,</span>
|
|
<span class="Identifier">FoundEncryptedSecretButNoPasswordHandlerException</span><span class="Other">,</span>
|
|
<span class="Identifier">PasswordSetToAtomicButMissingEncryptedKeyidException</span><span class="Other">,</span>
|
|
<span class="Identifier">IncorrectPasswordForSecretKeyException</span><span class="Other">,</span> <span class="Identifier">IncorrectKeyFlagsException</span><span class="Other">,</span>
|
|
<span class="Identifier">CertIsInvalidException</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
<p>Applies the <tt class="docutils literal"><span class="pre"><span class="Identifier">newPassword</span></span></tt> specifications to the given cert.</p>
|
|
<p>Allows for re-encryption of a key with <tt class="docutils literal"><span class="pre"><span class="Identifier">oldPassword</span></span></tt>, which corresponds ot the current decryption method.</p>
|
|
<hr />
|
|
<p>Capable of raising the following exceptions:</p>
|
|
<p><a class="reference internal nimdoc" title="object FailedToParseKeyPrivateException" href="#FailedToParseKeyPrivateException">FailedToParseKeyPrivateException</a>, <a class="reference internal nimdoc" title="object ExpectedPrivateKeyGotPublicException" href="#ExpectedPrivateKeyGotPublicException">ExpectedPrivateKeyGotPublicException</a>, <a class="reference internal nimdoc" title="object NoKeyMeetsSelectionException" href="#NoKeyMeetsSelectionException">NoKeyMeetsSelectionException</a></p>
|
|
<p><a class="reference internal nimdoc" title="object FailedToEncryptKeyException" href="#FailedToEncryptKeyException">FailedToEncryptKeyException</a>, <a class="reference internal nimdoc" title="object FailedToWriteMessageException" href="#FailedToWriteMessageException">FailedToWriteMessageException</a>, <a class="reference internal" href="#CertIsInvalidException">CertIsInvalidException</a></p>
|
|
|
|
<p><strong class="examples_text">Example:</strong></p>
|
|
<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">nimPGP</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">signingKey</span> <span class="Operator">=</span> <span class="Identifier">newSubkey</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="Identifier">ForSigning</span><span class="Punctuation">}</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">transportKey</span> <span class="Operator">=</span> <span class="Identifier">newSubkey</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="Identifier">ForTransport</span><span class="Punctuation">}</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">unencryptedCert</span> <span class="Operator">=</span> <span class="Identifier">newCert</span><span class="Punctuation">(</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="Identifier">signingKey</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">pwHandler</span> <span class="Operator">=</span> <span class="Identifier">newPasswordHandler</span><span class="Punctuation">(</span><span class="StringLit">"password12345!"</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">certEncrypted</span> <span class="Operator">=</span><span class="Identifier">encryptKeys</span><span class="Punctuation">(</span><span class="Identifier">unencryptedCert</span><span class="Punctuation">,</span> <span class="Identifier">pwHandler</span><span class="Punctuation">)</span></pre>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
<div id="getRecipients-procs-all">
|
|
<div id="getRecipients,string">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#getRecipients%2Cstring"><span class="Identifier">getRecipients</span></a><span class="Other">(</span><span class="Identifier">message</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span>
|
|
<span class="Identifier">FailedToWriteMessageException</span><span class="Other">,</span> <span class="Identifier">ExpectedPrivateKeyGotPublicException</span><span class="Other">,</span>
|
|
<span class="Identifier">FailedToParseKeyPublicException</span><span class="Other">,</span> <span class="Identifier">FailedToParseKeyPrivateException</span><span class="Other">,</span>
|
|
<span class="Identifier">NoKeyMeetsSelectionException</span><span class="Other">,</span> <span class="Identifier">FailedToParseMessageException</span><span class="Other">,</span>
|
|
<span class="Identifier">PackedParserFailedToRecurseException</span><span class="Other">,</span> <span class="Identifier">FailedToReadFromBufferException</span><span class="Other">,</span>
|
|
<span class="Identifier">CertGenerationFailedException</span><span class="Other">,</span> <span class="Identifier">FailedToParseKeyException</span><span class="Other">,</span>
|
|
<span class="Identifier">CertRevokedException</span><span class="Other">,</span> <span class="Identifier">FailedToRevokeSubkeyException</span><span class="Other">,</span>
|
|
<span class="Identifier">FailedToRevokePrimaryKeyException</span><span class="Other">,</span> <span class="Identifier">FailedToEncryptKeyException</span><span class="Other">,</span>
|
|
<span class="Identifier">CertMaybeRevokedException</span><span class="Other">,</span>
|
|
<span class="Identifier">FoundEncryptedSecretButNoPasswordHandlerException</span><span class="Other">,</span>
|
|
<span class="Identifier">PasswordSetToAtomicButMissingEncryptedKeyidException</span><span class="Other">,</span>
|
|
<span class="Identifier">IncorrectPasswordForSecretKeyException</span><span class="Other">,</span> <span class="Identifier">IncorrectKeyFlagsException</span><span class="Other">,</span>
|
|
<span class="Identifier">CertIsInvalidException</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
Gets the keyids for which a pgp message is encrypted for.<hr />
|
|
<p>Capable of raising the following exceptions:</p>
|
|
<p><a class="reference internal nimdoc" title="object FailedToParseMessageException" href="#FailedToParseMessageException">FailedToParseMessageException</a>, <a class="reference internal nimdoc" title="object PackedParserFailedToRecurseException" href="#PackedParserFailedToRecurseException">PackedParserFailedToRecurseException</a>, <a class="reference internal" href="#CertIsInvalidException">CertIsInvalidException</a></p>
|
|
|
|
<p><strong class="examples_text">Example:</strong></p>
|
|
<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">nimPGP</span>
|
|
<span class="Keyword">import</span> <span class="Identifier">sequtils</span>
|
|
<span class="Keyword">import</span> <span class="Identifier">sugar</span>
|
|
<span class="Keyword">import</span> <span class="Identifier">tables</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">certOne</span> <span class="Operator">=</span> <span class="Identifier">newCert</span><span class="Punctuation">(</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="Identifier">newSubkey</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="Identifier">ForTransport</span><span class="Punctuation">}</span><span class="Punctuation">)</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">certTwo</span> <span class="Operator">=</span> <span class="Identifier">newCert</span><span class="Punctuation">(</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="Identifier">newSubkey</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="Identifier">ForTransport</span><span class="Punctuation">}</span><span class="Punctuation">)</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">message</span> <span class="Operator">=</span> <span class="Identifier">sendMessage</span><span class="Punctuation">(</span><span class="Identifier">certOne</span><span class="Operator">.</span><span class="Identifier">private</span><span class="Punctuation">,</span> <span class="StringLit">"for your eyes only!"</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">recipients</span> <span class="Operator">=</span> <span class="Identifier">getRecipients</span> <span class="Identifier">message</span>
|
|
|
|
<span class="Identifier">echo</span> <span class="Identifier">recipients</span><span class="Operator">.</span><span class="Identifier">any</span><span class="Punctuation">(</span><span class="Identifier">x</span> <span class="Operator">=></span> <span class="Identifier">x</span> <span class="Keyword">in</span> <span class="Identifier">certOne</span><span class="Operator">.</span><span class="Identifier">subkeys</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">echo</span> <span class="Identifier">recipients</span><span class="Operator">.</span><span class="Identifier">any</span><span class="Punctuation">(</span><span class="Identifier">x</span> <span class="Operator">=></span> <span class="Identifier">x</span> <span class="Keyword">in</span> <span class="Identifier">certTwo</span><span class="Operator">.</span><span class="Identifier">subkeys</span><span class="Punctuation">)</span></pre>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
<div id="isPrimaryKeyRevoked-procs-all">
|
|
<div id="isPrimaryKeyRevoked,PublicKey">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#isPrimaryKeyRevoked%2CPublicKey"><span class="Identifier">isPrimaryKeyRevoked</span></a><span class="Other">(</span><span class="Identifier">key</span><span class="Other">:</span> <a href="nimPGP.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">)</span><span class="Other">:</span> <a href="binding.html#RevocationStatus"><span class="Identifier">RevocationStatus</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span>
|
|
<span class="Identifier">FailedToWriteMessageException</span><span class="Other">,</span> <span class="Identifier">ExpectedPrivateKeyGotPublicException</span><span class="Other">,</span>
|
|
<span class="Identifier">FailedToParseKeyPublicException</span><span class="Other">,</span> <span class="Identifier">FailedToParseKeyPrivateException</span><span class="Other">,</span>
|
|
<span class="Identifier">NoKeyMeetsSelectionException</span><span class="Other">,</span> <span class="Identifier">FailedToParseMessageException</span><span class="Other">,</span>
|
|
<span class="Identifier">PackedParserFailedToRecurseException</span><span class="Other">,</span> <span class="Identifier">FailedToReadFromBufferException</span><span class="Other">,</span>
|
|
<span class="Identifier">CertGenerationFailedException</span><span class="Other">,</span> <span class="Identifier">FailedToParseKeyException</span><span class="Other">,</span>
|
|
<span class="Identifier">CertRevokedException</span><span class="Other">,</span> <span class="Identifier">FailedToRevokeSubkeyException</span><span class="Other">,</span>
|
|
<span class="Identifier">FailedToRevokePrimaryKeyException</span><span class="Other">,</span> <span class="Identifier">FailedToEncryptKeyException</span><span class="Other">,</span>
|
|
<span class="Identifier">CertMaybeRevokedException</span><span class="Other">,</span>
|
|
<span class="Identifier">FoundEncryptedSecretButNoPasswordHandlerException</span><span class="Other">,</span>
|
|
<span class="Identifier">PasswordSetToAtomicButMissingEncryptedKeyidException</span><span class="Other">,</span>
|
|
<span class="Identifier">IncorrectPasswordForSecretKeyException</span><span class="Other">,</span> <span class="Identifier">IncorrectKeyFlagsException</span><span class="Other">,</span>
|
|
<span class="Identifier">CertIsInvalidException</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
To revoke a primary key, see <a class="reference internal" href="#RevokePrimaryKey">RevokePrimaryKey</a>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
<div id="isSubkeyRevoked-procs-all">
|
|
<div id="isSubkeyRevoked,PublicKey,">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#isSubkeyRevoked%2CPublicKey%2C"><span class="Identifier">isSubkeyRevoked</span></a><span class="Other">(</span><span class="Identifier">key</span><span class="Other">:</span> <a href="nimPGP.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">;</span> <span class="Identifier">keyid</span><span class="Other">:</span> <span class="Identifier">string</span> <span class="Keyword">or</span> <a href="nimPGP.html#Subkey"><span class="Identifier">Subkey</span></a><span class="Other">)</span><span class="Other">:</span> <a href="binding.html#RevocationStatus"><span class="Identifier">RevocationStatus</span></a></pre></dt>
|
|
<dd>
|
|
|
|
To revoke a subkey, see <a class="reference internal" href="#RevokeSubkey">RevokeSubkey</a>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
<div id="newCert-procs-all">
|
|
<div id="newCert,,CryptSuites,seq[string]">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#newCert%2C%2CCryptSuites%2Cseq%5Bstring%5D"><span class="Identifier">newCert</span></a><span class="Other">(</span><span class="Identifier">subkeySeq</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><a href="nimPGP.html#UninitiatedSubkey"><span class="Identifier">UninitiatedSubkey</span></a><span class="Other">]</span> <span class="Operator">|</span> <span class="Identifier">openArray</span><span class="Other">[</span><a href="nimPGP.html#UninitiatedSubkey"><span class="Identifier">UninitiatedSubkey</span></a><span class="Other">]</span><span class="Other">;</span>
|
|
<span class="Identifier">primaryCipher</span><span class="Other">:</span> <a href="binding.html#CryptSuites"><span class="Identifier">CryptSuites</span></a> <span class="Other">=</span> <span class="Identifier">Cv25519</span><span class="Other">;</span> <span class="Identifier">user_ids</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span> <span class="Other">=</span> <span class="Operator">@</span><span class="Other">[</span><span class="Other">]</span><span class="Other">;</span>
|
|
<span class="Identifier">validLength</span><span class="Other">:</span> <span class="Identifier">uint32</span> <span class="Operator">|</span> <span class="Identifier">Duration</span> <span class="Other">=</span> <span class="Identifier">uint32</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="nimPGP.html#Cert"><span class="Identifier">Cert</span></a></pre></dt>
|
|
<dd>
|
|
|
|
<p>Generates a new PGP Cert.</p>
|
|
<p>A given Cert can have a maximum of 256 unique subkeys, this applies to both <a class="reference internal nimdoc" title="proc scaffoldKey(key: PublicKey or PrivateKey): Cert" href="#scaffoldKey">scaffoldKey</a> and this procedure. This can be boosted if people have issues.</p>
|
|
<p>validLength takes in either a uint32 in seconds or a duration.</p>
|
|
<p>It is the length of time until it expires, e.g <tt class="docutils literal"><span class="pre"><span class="Identifier">validLength</span> <span class="Operator">=</span> <span class="DecNumber">60</span><span class="Operator">*</span><span class="DecNumber">60</span><span class="Operator">*</span><span class="DecNumber">24</span><span class="Operator">*</span><span class="DecNumber">365</span> <span class="Operator">=</span> <span class="Operator">~</span><span class="DecNumber">1</span> <span class="Identifier">year</span></span></tt> until expiry. If it was made on 1/1/2050 it would expire on 1/1/2051</p>
|
|
<p>If Duration > 2^32 (4294967295, uint32.high, ~136.192 years) then a <a class="reference internal" href="#OverflowDefect">OverflowDefect</a> is raised. This is because duration on the Rust side uses SystemTime, which has a maximum of u32 when accepting from seconds</p>
|
|
<p>The minimum length until it is invalid duration is 100 seconds.</p>
|
|
<p>Note: Due to Sequoia's security limitations, you CANNOT make a key which both signs and encrypts data This would raise a <a class="reference external" href="#KeyCannotBeUsedForTransportAndSigningException">KeyCannotBeUsedForTransportAndSigningException</a> inherited from <a class="reference internal nimdoc" title="object CertGenerationFailedException" href="#CertGenerationFailedException">CertGenerationFailedException</a></p>
|
|
<p>Also note: Keys Generated with new cert are not encrypted. To encrypt them see <tt class="docutils literal"><span class="pre"><span class="Identifier">encryptKeys</span></span></tt></p>
|
|
<p>There is a maximum of 254 subkeys per key</p>
|
|
<hr />
|
|
<p>Capable of raising: <a class="reference internal nimdoc" title="object CertGenerationFailedException" href="#CertGenerationFailedException">CertGenerationFailedException</a>, <a class="reference internal nimdoc" title="object FailedToWriteMessageException" href="#FailedToWriteMessageException">FailedToWriteMessageException</a></p>
|
|
|
|
<p><strong class="examples_text">Example:</strong></p>
|
|
<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">nimPGP</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">signingKey</span> <span class="Operator">=</span> <span class="Identifier">newSubkey</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="Identifier">ForSigning</span><span class="Punctuation">}</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">transportKey</span> <span class="Operator">=</span> <span class="Identifier">newSubkey</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="Identifier">ForTransport</span><span class="Punctuation">}</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">cert</span> <span class="Operator">=</span> <span class="Identifier">newCert</span><span class="Punctuation">(</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="Identifier">signingKey</span><span class="Punctuation">,</span> <span class="Identifier">transportKey</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">signedMessage</span> <span class="Operator">=</span> <span class="Identifier">signMessage</span><span class="Punctuation">(</span><span class="Identifier">cert</span><span class="Operator">.</span><span class="Identifier">private</span><span class="Punctuation">,</span> <span class="StringLit">"Hello, World!"</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">verification</span> <span class="Operator">=</span> <span class="Identifier">verifySignature</span><span class="Punctuation">(</span><span class="Identifier">cert</span><span class="Operator">.</span><span class="Identifier">public</span><span class="Punctuation">,</span> <span class="Identifier">signedMessage</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">doAssert</span> <span class="Identifier">verification</span><span class="Operator">.</span><span class="Identifier">isValid</span> <span class="Operator">==</span> <span class="Identifier">true</span>
|
|
<span class="Identifier">doAssert</span> <span class="Identifier">verification</span><span class="Operator">.</span><span class="Identifier">body</span> <span class="Operator">==</span> <span class="StringLit">"Hello, World!"</span></pre>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
<div id="newPasswordHandler-procs-all">
|
|
<div id="newPasswordHandler,string">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#newPasswordHandler%2Cstring"><span class="Identifier">newPasswordHandler</span></a><span class="Other">(</span><span class="Identifier">globalPassword</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <a href="nimPGP.html#GlobalPasswordHandler"><span class="Identifier">GlobalPasswordHandler</span></a> {.
|
|
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
<p>Creates a password handler where, one password is used for all keys.</p>
|
|
<p>There is an overload function which takes in a <tt class="docutils literal"><span class="pre"><span class="Identifier">Table</span><span class="Punctuation">[</span><span class="Identifier">string</span><span class="Punctuation">,</span> <span class="Identifier">string</span><span class="Punctuation">]</span></span></tt> for atomic password handling.</p>
|
|
<p>This also encrypts the primary key.</p>
|
|
<p>A GlobalPasswordHandler cannot be used in <a class="reference internal nimdoc" title="proc newPasswordHandlerKeyring(handlers: varargs[AtomicPasswordHandler]): AtomicPasswordHandler" href="#newPasswordHandlerKeyring,varargs[AtomicPasswordHandler]">newPasswordHandlerKeyring</a> and needs to be converted into an AtomicPasswordHandler using <a class="reference internal nimdoc" title="proc convertGlobalPasswordToAtomic(a: Cert; b: GlobalPasswordHandler): AtomicPasswordHandler" href="#convertGlobalPasswordToAtomic,Cert,GlobalPasswordHandler">convertGlobalPasswordToAtomic</a>. </p>
|
|
|
|
<p><strong class="examples_text">Example:</strong></p>
|
|
<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">nimPGP</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">signingKey</span> <span class="Operator">=</span> <span class="Identifier">newSubkey</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="Identifier">ForSigning</span><span class="Punctuation">}</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">transportKey</span> <span class="Operator">=</span> <span class="Identifier">newSubkey</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="Identifier">ForTransport</span><span class="Punctuation">}</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">certUnencrypted</span> <span class="Operator">=</span> <span class="Identifier">newCert</span><span class="Punctuation">(</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="Identifier">signingKey</span><span class="Punctuation">,</span> <span class="Identifier">transportKey</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">pwHandler</span> <span class="Operator">=</span> <span class="Identifier">newPasswordHandler</span><span class="Punctuation">(</span><span class="StringLit">"A really super duper good password!"</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">certEncrypted</span> <span class="Operator">=</span> <span class="Identifier">encryptKeys</span><span class="Punctuation">(</span><span class="Identifier">certUnencrypted</span><span class="Punctuation">,</span> <span class="Identifier">pwHandler</span><span class="Punctuation">)</span></pre>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="newPasswordHandler,Table[string,string]">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#newPasswordHandler%2CTable%5Bstring%2Cstring%5D"><span class="Identifier">newPasswordHandler</span></a><span class="Other">(</span><span class="Identifier">keyidToPassword</span><span class="Other">:</span> <span class="Identifier">Table</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">,</span> <span class="Identifier">string</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="nimPGP.html#AtomicPasswordHandler"><span class="Identifier">AtomicPasswordHandler</span></a> {.
|
|
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
<p>Creates a password handler where, each keyid provided has a unique password.</p>
|
|
<p>Not all keyids are required to be in the table, they will not be encrypted.</p>
|
|
|
|
<p><strong class="examples_text">Example:</strong></p>
|
|
<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">nimPGP</span>
|
|
<span class="Keyword">import</span> <span class="Identifier">sequtils</span>
|
|
<span class="Keyword">import</span> <span class="Identifier">tables</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">signingKey</span> <span class="Operator">=</span> <span class="Identifier">newSubkey</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="Identifier">ForSigning</span><span class="Punctuation">}</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">transportKey</span> <span class="Operator">=</span> <span class="Identifier">newSubkey</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="Identifier">ForTransport</span><span class="Punctuation">}</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">unencryptedCert</span> <span class="Operator">=</span> <span class="Identifier">newCert</span><span class="Punctuation">(</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="Identifier">signingKey</span><span class="Punctuation">,</span> <span class="Identifier">transportKey</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">keys</span> <span class="Operator">=</span> <span class="Identifier">unencryptedCert</span><span class="Operator">.</span><span class="Identifier">primaryKeyId</span> <span class="Operator">&</span> <span class="Identifier">unencryptedCert</span><span class="Operator">.</span><span class="Identifier">subkeys</span><span class="Operator">.</span><span class="Identifier">keys</span><span class="Operator">.</span><span class="Identifier">toSeq</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">pwHandler</span> <span class="Operator">=</span> <span class="Identifier">newPasswordHandler</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="Identifier">keys</span><span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">]</span> <span class="Punctuation">:</span> <span class="StringLit">"a"</span><span class="Punctuation">,</span> <span class="Identifier">keys</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">]</span> <span class="Punctuation">:</span> <span class="StringLit">"b"</span><span class="Punctuation">,</span> <span class="Identifier">keys</span><span class="Punctuation">[</span><span class="DecNumber">2</span><span class="Punctuation">]</span> <span class="Punctuation">:</span> <span class="StringLit">"c"</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toTable</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">certEncrypted</span> <span class="Operator">=</span> <span class="Identifier">encryptKeys</span><span class="Punctuation">(</span><span class="Identifier">unencryptedCert</span><span class="Punctuation">,</span> <span class="Identifier">pwHandler</span><span class="Punctuation">)</span></pre>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
<div id="newPasswordHandlerKeyring-procs-all">
|
|
<div id="newPasswordHandlerKeyring,varargs[AtomicPasswordHandler]">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#newPasswordHandlerKeyring%2Cvarargs%5BAtomicPasswordHandler%5D"><span class="Identifier">newPasswordHandlerKeyring</span></a><span class="Other">(</span><span class="Identifier">handlers</span><span class="Other">:</span> <span class="Identifier">varargs</span><span class="Other">[</span><a href="nimPGP.html#AtomicPasswordHandler"><span class="Identifier">AtomicPasswordHandler</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="nimPGP.html#AtomicPasswordHandler"><span class="Identifier">AtomicPasswordHandler</span></a> {.
|
|
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
<div id="newSubkey-procs-all">
|
|
<div id="newSubkey,set[KeyTypes],CryptSuites">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#newSubkey%2Cset%5BKeyTypes%5D%2CCryptSuites"><span class="Identifier">newSubkey</span></a><span class="Other">(</span><span class="Identifier">keyFlags</span><span class="Other">:</span> <span class="Identifier">set</span><span class="Other">[</span><a href="binding.html#KeyTypes"><span class="Identifier">KeyTypes</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">cipher</span><span class="Other">:</span> <a href="binding.html#CryptSuites"><span class="Identifier">CryptSuites</span></a> <span class="Other">=</span> <span class="Identifier">Cv25519</span><span class="Other">;</span>
|
|
<span class="Identifier">validLength</span><span class="Other">:</span> <span class="Identifier">uint32</span> <span class="Keyword">or</span> <span class="Identifier">Duration</span> <span class="Other">=</span> <span class="Identifier">uint32</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="nimPGP.html#UninitiatedSubkey"><span class="Identifier">UninitiatedSubkey</span></a></pre></dt>
|
|
<dd>
|
|
|
|
<p>Creates a new UninitiatedSubkey which can be turned into a subkey in <a class="reference internal" href="#NewCert">NewCert</a></p>
|
|
<p>Note: While you can put arbitrary ciphers for a given key, the ciphers are unknowable due to Sequoia side reasons.</p>
|
|
<p>Thus, I recommend you not use whacky combinations of ciphers, unless you want reconstruct your ciphers using the flags and validLength, which i do not recommend as this is a a very recognizable fingerprint.</p>
|
|
<p>ValidLength is in seconds, see <a class="reference internal nimdoc" title="proc newCert(subkeySeq: seq[UninitiatedSubkey] | openArray[UninitiatedSubkey];
|
|
primaryCipher: CryptSuites = Cv25519; user_ids: seq[string] = @[];
|
|
validLength: uint32 | Duration = uint32 0): Cert" href="#newCert,,CryptSuites,seq[string]">newCert</a> for more detail</p>
|
|
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
<div id="revokePrimaryKey-procs-all">
|
|
<div id="revokePrimaryKey,Cert,ReasonForRevocation,string">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#revokePrimaryKey%2CCert%2CReasonForRevocation%2Cstring"><span class="Identifier">revokePrimaryKey</span></a><span class="Other">(</span><span class="Identifier">cert</span><span class="Other">:</span> <a href="nimPGP.html#Cert"><span class="Identifier">Cert</span></a><span class="Other">;</span> <span class="Identifier">reason</span><span class="Other">:</span> <a href="binding.html#ReasonForRevocation"><span class="Identifier">ReasonForRevocation</span></a> <span class="Other">=</span> <span class="Identifier">Unspecified</span><span class="Other">;</span>
|
|
<span class="Identifier">message</span><span class="Other">:</span> <span class="Identifier">string</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span> <span class="Identifier">passwordHandler</span> <span class="Other">=</span> <a href="nimPGP.html#PasswordHandler"><span class="Identifier">PasswordHandler</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">)</span><span class="Other">:</span> <a href="nimPGP.html#Cert"><span class="Identifier">Cert</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span>
|
|
<span class="Identifier">CertLacksPrivateKey</span><span class="Other">,</span> <span class="Identifier">FailedToWriteMessageException</span><span class="Other">,</span>
|
|
<span class="Identifier">ExpectedPrivateKeyGotPublicException</span><span class="Other">,</span> <span class="Identifier">FailedToParseKeyPublicException</span><span class="Other">,</span>
|
|
<span class="Identifier">FailedToParseKeyPrivateException</span><span class="Other">,</span> <span class="Identifier">NoKeyMeetsSelectionException</span><span class="Other">,</span>
|
|
<span class="Identifier">FailedToParseMessageException</span><span class="Other">,</span> <span class="Identifier">PackedParserFailedToRecurseException</span><span class="Other">,</span>
|
|
<span class="Identifier">FailedToReadFromBufferException</span><span class="Other">,</span> <span class="Identifier">CertGenerationFailedException</span><span class="Other">,</span>
|
|
<span class="Identifier">FailedToParseKeyException</span><span class="Other">,</span> <span class="Identifier">CertRevokedException</span><span class="Other">,</span>
|
|
<span class="Identifier">FailedToRevokeSubkeyException</span><span class="Other">,</span> <span class="Identifier">FailedToRevokePrimaryKeyException</span><span class="Other">,</span>
|
|
<span class="Identifier">FailedToEncryptKeyException</span><span class="Other">,</span> <span class="Identifier">CertMaybeRevokedException</span><span class="Other">,</span>
|
|
<span class="Identifier">FoundEncryptedSecretButNoPasswordHandlerException</span><span class="Other">,</span>
|
|
<span class="Identifier">PasswordSetToAtomicButMissingEncryptedKeyidException</span><span class="Other">,</span>
|
|
<span class="Identifier">IncorrectPasswordForSecretKeyException</span><span class="Other">,</span> <span class="Identifier">IncorrectKeyFlagsException</span><span class="Other">,</span>
|
|
<span class="Identifier">CertIsInvalidException</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
To check if a primary key is revoked, see <a class="reference internal nimdoc" title="proc isPrimaryKeyRevoked(key: PublicKey): RevocationStatus" href="#isPrimaryKeyRevoked,PublicKey">isPrimaryKeyRevoked</a><hr />
|
|
<p>Capable of raising the following exceptions:</p>
|
|
<p><a class="reference internal nimdoc" title="object FailedToParseKeyPrivateException" href="#FailedToParseKeyPrivateException">FailedToParseKeyPrivateException</a>, <a class="reference internal nimdoc" title="object ExpectedPrivateKeyGotPublicException" href="#ExpectedPrivateKeyGotPublicException">ExpectedPrivateKeyGotPublicException</a>, <a class="reference internal nimdoc" title="object NoKeyMeetsSelectionException" href="#NoKeyMeetsSelectionException">NoKeyMeetsSelectionException</a></p>
|
|
<p><a class="reference internal nimdoc" title="object FailedToRevokePrimaryKeyException" href="#FailedToRevokePrimaryKeyException">FailedToRevokePrimaryKeyException</a>, <a class="reference internal nimdoc" title="object FailedToWriteMessageException" href="#FailedToWriteMessageException">FailedToWriteMessageException</a>, <a class="reference internal" href="#CertIsInvalidException">CertIsInvalidException</a></p>
|
|
<p><a class="reference internal nimdoc" title="object IncorrectPasswordForSecretKeyException" href="#IncorrectPasswordForSecretKeyException">IncorrectPasswordForSecretKeyException</a>, <a class="reference internal nimdoc" title="object FoundEncryptedSecretButNoPasswordHandlerException" href="#FoundEncryptedSecretButNoPasswordHandlerException">FoundEncryptedSecretButNoPasswordHandlerException</a>, <a class="reference internal nimdoc" title="object PasswordSetToAtomicButMissingEncryptedKeyidException" href="#PasswordSetToAtomicButMissingEncryptedKeyidException">PasswordSetToAtomicButMissingEncryptedKeyidException</a></p>
|
|
|
|
<p><strong class="examples_text">Example:</strong></p>
|
|
<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">nimPGP</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">cert</span> <span class="Operator">=</span> <span class="Identifier">newCert</span><span class="Punctuation">(</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="Identifier">newSubkey</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="Identifier">ForSigning</span><span class="Punctuation">}</span><span class="Punctuation">)</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">revokedCert</span> <span class="Operator">=</span> <span class="Identifier">revokePrimaryKey</span><span class="Punctuation">(</span><span class="Identifier">cert</span><span class="Punctuation">,</span> <span class="Identifier">reason</span> <span class="Operator">=</span> <span class="Identifier">KeyRetired</span><span class="Punctuation">,</span> <span class="StringLit">"I got bored of this key"</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">echo</span> <span class="Identifier">isPrimaryKeyRevoked</span><span class="Punctuation">(</span><span class="Identifier">revokedCert</span><span class="Operator">.</span><span class="Identifier">public</span><span class="Punctuation">)</span></pre>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
<div id="revokeSubkey-procs-all">
|
|
<div id="revokeSubkey,Cert,string,ReasonForRevocation,string">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#revokeSubkey%2CCert%2Cstring%2CReasonForRevocation%2Cstring"><span class="Identifier">revokeSubkey</span></a><span class="Other">(</span><span class="Identifier">cert</span><span class="Other">:</span> <a href="nimPGP.html#Cert"><span class="Identifier">Cert</span></a><span class="Other">;</span> <span class="Identifier">subkey_keyid</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span>
|
|
<span class="Identifier">reason</span><span class="Other">:</span> <a href="binding.html#ReasonForRevocation"><span class="Identifier">ReasonForRevocation</span></a> <span class="Other">=</span> <span class="Identifier">Unspecified</span><span class="Other">;</span>
|
|
<span class="Identifier">message</span><span class="Other">:</span> <span class="Identifier">string</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span> <span class="Identifier">passwordHandler</span> <span class="Other">=</span> <a href="nimPGP.html#PasswordHandler"><span class="Identifier">PasswordHandler</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">)</span><span class="Other">:</span> <a href="nimPGP.html#Cert"><span class="Identifier">Cert</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span>
|
|
<span class="Identifier">CertLacksPrivateKey</span><span class="Other">,</span> <span class="Identifier">FailedToWriteMessageException</span><span class="Other">,</span>
|
|
<span class="Identifier">ExpectedPrivateKeyGotPublicException</span><span class="Other">,</span> <span class="Identifier">FailedToParseKeyPublicException</span><span class="Other">,</span>
|
|
<span class="Identifier">FailedToParseKeyPrivateException</span><span class="Other">,</span> <span class="Identifier">NoKeyMeetsSelectionException</span><span class="Other">,</span>
|
|
<span class="Identifier">FailedToParseMessageException</span><span class="Other">,</span> <span class="Identifier">PackedParserFailedToRecurseException</span><span class="Other">,</span>
|
|
<span class="Identifier">FailedToReadFromBufferException</span><span class="Other">,</span> <span class="Identifier">CertGenerationFailedException</span><span class="Other">,</span>
|
|
<span class="Identifier">FailedToParseKeyException</span><span class="Other">,</span> <span class="Identifier">CertRevokedException</span><span class="Other">,</span>
|
|
<span class="Identifier">FailedToRevokeSubkeyException</span><span class="Other">,</span> <span class="Identifier">FailedToRevokePrimaryKeyException</span><span class="Other">,</span>
|
|
<span class="Identifier">FailedToEncryptKeyException</span><span class="Other">,</span> <span class="Identifier">CertMaybeRevokedException</span><span class="Other">,</span>
|
|
<span class="Identifier">FoundEncryptedSecretButNoPasswordHandlerException</span><span class="Other">,</span>
|
|
<span class="Identifier">PasswordSetToAtomicButMissingEncryptedKeyidException</span><span class="Other">,</span>
|
|
<span class="Identifier">IncorrectPasswordForSecretKeyException</span><span class="Other">,</span> <span class="Identifier">IncorrectKeyFlagsException</span><span class="Other">,</span>
|
|
<span class="Identifier">CertIsInvalidException</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
To check if a subkey is revoked, see <a class="reference internal nimdoc" title="proc isSubkeyRevoked(key: PublicKey; keyid: string or Subkey): RevocationStatus" href="#isSubkeyRevoked,PublicKey,">isSubkeyRevoked</a><hr />
|
|
<p>Capable of raising the following exceptions:</p>
|
|
<p><a class="reference internal nimdoc" title="object FailedToParseKeyPrivateException" href="#FailedToParseKeyPrivateException">FailedToParseKeyPrivateException</a>, <a class="reference internal nimdoc" title="object ExpectedPrivateKeyGotPublicException" href="#ExpectedPrivateKeyGotPublicException">ExpectedPrivateKeyGotPublicException</a>, <a class="reference internal nimdoc" title="object NoKeyMeetsSelectionException" href="#NoKeyMeetsSelectionException">NoKeyMeetsSelectionException</a></p>
|
|
<p><a class="reference internal nimdoc" title="object FailedToRevokeSubkeyException" href="#FailedToRevokeSubkeyException">FailedToRevokeSubkeyException</a>, <a class="reference internal nimdoc" title="object FailedToWriteMessageException" href="#FailedToWriteMessageException">FailedToWriteMessageException</a>, <a class="reference internal" href="#CertIsInvalidException">CertIsInvalidException</a></p>
|
|
<p><a class="reference internal nimdoc" title="object IncorrectPasswordForSecretKeyException" href="#IncorrectPasswordForSecretKeyException">IncorrectPasswordForSecretKeyException</a>, <a class="reference internal nimdoc" title="object FoundEncryptedSecretButNoPasswordHandlerException" href="#FoundEncryptedSecretButNoPasswordHandlerException">FoundEncryptedSecretButNoPasswordHandlerException</a>, <a class="reference internal nimdoc" title="object PasswordSetToAtomicButMissingEncryptedKeyidException" href="#PasswordSetToAtomicButMissingEncryptedKeyidException">PasswordSetToAtomicButMissingEncryptedKeyidException</a></p>
|
|
|
|
<p><strong class="examples_text">Example:</strong></p>
|
|
<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">nimPGP</span>
|
|
<span class="Keyword">import</span> <span class="Identifier">tables</span>
|
|
<span class="Keyword">import</span> <span class="Identifier">sequtils</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">cert</span> <span class="Operator">=</span> <span class="Identifier">newCert</span><span class="Punctuation">(</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="Identifier">newSubkey</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="Identifier">ForSigning</span><span class="Punctuation">}</span><span class="Punctuation">)</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
|
<span class="Comment"># returns a new Cert, does not mutate the previous one</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">subkey</span> <span class="Operator">=</span> <span class="Identifier">cert</span><span class="Operator">.</span><span class="Identifier">subkeys</span><span class="Operator">.</span><span class="Identifier">keys</span><span class="Operator">.</span><span class="Identifier">toSeq</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">]</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">revokedCert</span> <span class="Operator">=</span> <span class="Identifier">revokeSubkey</span><span class="Punctuation">(</span><span class="Identifier">cert</span><span class="Punctuation">,</span> <span class="Identifier">subkey</span><span class="Punctuation">,</span> <span class="Identifier">reason</span> <span class="Operator">=</span> <span class="Identifier">KeyRetired</span><span class="Punctuation">,</span> <span class="StringLit">"I got bored of this key"</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">echo</span> <span class="Identifier">isSubkeyRevoked</span><span class="Punctuation">(</span><span class="Identifier">revokedCert</span><span class="Operator">.</span><span class="Identifier">public</span><span class="Punctuation">,</span> <span class="Identifier">subkey</span><span class="Punctuation">)</span></pre>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
<div id="scaffoldKey-procs-all">
|
|
<div id="scaffoldKey">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#scaffoldKey"><span class="Identifier">scaffoldKey</span></a><span class="Other">(</span><span class="Identifier">key</span><span class="Other">:</span> <a href="nimPGP.html#PublicKey"><span class="Identifier">PublicKey</span></a> <span class="Keyword">or</span> <a href="nimPGP.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">)</span><span class="Other">:</span> <a href="nimPGP.html#Cert"><span class="Identifier">Cert</span></a></pre></dt>
|
|
<dd>
|
|
|
|
Takes in a private or public key, and parses the keys. If a public key is provided, there will be no private key field.<hr />
|
|
<p>Capable of raising the following exceptions:</p>
|
|
<p><a class="reference internal nimdoc" title="object FailedToParseKeyException" href="#FailedToParseKeyException">FailedToParseKeyException</a>, <a class="reference internal nimdoc" title="object FailedToWriteMessageException" href="#FailedToWriteMessageException">FailedToWriteMessageException</a>, <a class="reference internal" href="#CertIsInvalidException">CertIsInvalidException</a></p>
|
|
|
|
<p><strong class="examples_text">Example:</strong></p>
|
|
<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">nimPGP</span>
|
|
<span class="Keyword">import</span> <span class="Identifier">tables</span>
|
|
<span class="Keyword">import</span> <span class="Identifier">sequtils</span>
|
|
<span class="Keyword">import</span> <span class="Identifier">json</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">privateKey</span> <span class="Operator">=</span> <span class="Identifier">parseJson</span><span class="Punctuation">(</span><span class="Identifier">readFile</span><span class="Punctuation">(</span><span class="StringLit">"./src/tests/foregin_certs.json"</span><span class="Punctuation">)</span><span class="Punctuation">)</span><span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">]</span><span class="Punctuation">[</span><span class="StringLit">"private"</span><span class="Punctuation">]</span><span class="Operator">.</span><span class="Identifier">getStr</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
|
|
<span class="Comment">#-----BEGIN PGP PRIVATE KEY BLOCK-----\n[data]----END PGP PRIVATE KEY BLOCK-----</span>
|
|
|
|
<span class="Identifier">echo</span> <span class="Identifier">scaffoldKey</span><span class="Punctuation">(</span><span class="Identifier">privateKey</span><span class="Punctuation">)</span></pre>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
<div id="sendMessage-procs-all">
|
|
<div id="sendMessage,,string">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#sendMessage%2C%2Cstring"><span class="Identifier">sendMessage</span></a><span class="Other">(</span><span class="Identifier">publicKeys</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><a href="nimPGP.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">]</span> <span class="Keyword">or</span> <a href="nimPGP.html#PublicKey"><span class="Identifier">PublicKey</span></a> <span class="Keyword">or</span> <span class="Identifier">seq</span><span class="Other">[</span><a href="nimPGP.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">]</span><span class="Other">;</span>
|
|
<span class="Identifier">message</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span></pre></dt>
|
|
<dd>
|
|
|
|
<p>For the inverse procedure, see <a class="reference internal" href="#DecryptMessage">DecryptMessage</a></p>
|
|
<p>Can take in a OpenArray<a class="reference internal" href="#"></a> or Seq<a class="reference internal" href="#"></a> if you wish to send to multiple public keys</p>
|
|
<hr />
|
|
<p>Capable of raising the following exceptions:</p>
|
|
<p><a class="reference internal nimdoc" title="object FailedToParseKeyPublicException" href="#FailedToParseKeyPublicException">FailedToParseKeyPublicException</a>, <a class="reference internal nimdoc" title="object CertRevokedException" href="#CertRevokedException">CertRevokedException</a>, <a class="reference internal nimdoc" title="object NoKeyMeetsSelectionException" href="#NoKeyMeetsSelectionException">NoKeyMeetsSelectionException</a></p>
|
|
<p><a class="reference internal nimdoc" title="object FailedToWriteMessageException" href="#FailedToWriteMessageException">FailedToWriteMessageException</a>, <a class="reference internal" href="#CertIsInvalidException">CertIsInvalidException</a></p>
|
|
|
|
<p><strong class="examples_text">Example:</strong></p>
|
|
<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">nimPGP</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">cert</span> <span class="Operator">=</span> <span class="Identifier">newCert</span><span class="Punctuation">(</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="Identifier">newSubkey</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="Identifier">ForTransport</span><span class="Punctuation">}</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">newSubkey</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="Identifier">ForSigning</span><span class="Punctuation">}</span><span class="Punctuation">)</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">signedMessage</span> <span class="Operator">=</span> <span class="Identifier">signMessage</span><span class="Punctuation">(</span><span class="Identifier">cert</span><span class="Operator">.</span><span class="Identifier">private</span><span class="Punctuation">,</span> <span class="StringLit">"Confidential Information"</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">echo</span> <span class="Identifier">sendMessage</span><span class="Punctuation">(</span><span class="Identifier">cert</span><span class="Operator">.</span><span class="Identifier">public</span><span class="Punctuation">,</span> <span class="Identifier">signedMessage</span><span class="Punctuation">)</span></pre>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
<div id="signMessage-procs-all">
|
|
<div id="signMessage,PrivateKey,string,string">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#signMessage%2CPrivateKey%2Cstring%2Cstring"><span class="Identifier">signMessage</span></a><span class="Other">(</span><span class="Identifier">privateKey</span><span class="Other">:</span> <a href="nimPGP.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">;</span> <span class="Identifier">message</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span>
|
|
<span class="Identifier">keyid</span><span class="Other">:</span> <span class="Identifier">string</span> <span class="Keyword">or</span> <a href="nimPGP.html#Subkey"><span class="Identifier">Subkey</span></a> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span>
|
|
<span class="Identifier">passwordHandler</span> <span class="Other">=</span> <a href="nimPGP.html#PasswordHandler"><span class="Identifier">PasswordHandler</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span></pre></dt>
|
|
<dd>
|
|
|
|
For the verification procedure, see <a class="reference internal nimdoc" title="proc verifySignature(publicKeys: openArray[PublicKey] or PublicKey or seq[string];
|
|
message: string): Verification" href="#verifySignature,,string">verifySignature</a><hr />
|
|
<p>Capable of raising the following exceptions:</p>
|
|
<p><a class="reference internal nimdoc" title="object FailedToParseKeyPrivateException" href="#FailedToParseKeyPrivateException">FailedToParseKeyPrivateException</a>, <a class="reference internal nimdoc" title="object ExpectedPrivateKeyGotPublicException" href="#ExpectedPrivateKeyGotPublicException">ExpectedPrivateKeyGotPublicException</a>, <a class="reference internal nimdoc" title="object CertRevokedException" href="#CertRevokedException">CertRevokedException</a>,</p>
|
|
<p><a class="reference internal nimdoc" title="object FailedToWriteMessageException" href="#FailedToWriteMessageException">FailedToWriteMessageException</a>, <a class="reference internal nimdoc" title="object NoKeyMeetsSelectionException" href="#NoKeyMeetsSelectionException">NoKeyMeetsSelectionException</a>, <a class="reference internal nimdoc" title="object IncorrectKeyFlagsException" href="#IncorrectKeyFlagsException">IncorrectKeyFlagsException</a>, <a class="reference internal" href="#CertIsInvalidException">CertIsInvalidException</a></p>
|
|
<p><a class="reference internal nimdoc" title="object IncorrectPasswordForSecretKeyException" href="#IncorrectPasswordForSecretKeyException">IncorrectPasswordForSecretKeyException</a>, <a class="reference internal nimdoc" title="object FoundEncryptedSecretButNoPasswordHandlerException" href="#FoundEncryptedSecretButNoPasswordHandlerException">FoundEncryptedSecretButNoPasswordHandlerException</a>, <a class="reference internal nimdoc" title="object PasswordSetToAtomicButMissingEncryptedKeyidException" href="#PasswordSetToAtomicButMissingEncryptedKeyidException">PasswordSetToAtomicButMissingEncryptedKeyidException</a></p>
|
|
|
|
<p><strong class="examples_text">Example:</strong></p>
|
|
<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">nimPGP</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">cert</span> <span class="Operator">=</span> <span class="Identifier">newCert</span><span class="Punctuation">(</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="Identifier">newSubkey</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="Identifier">ForSigning</span><span class="Punctuation">}</span><span class="Punctuation">)</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">doAssert</span> <span class="Punctuation">(</span><span class="Identifier">verifySignature</span><span class="Punctuation">(</span><span class="Identifier">cert</span><span class="Operator">.</span><span class="Identifier">public</span><span class="Punctuation">,</span><span class="Identifier">signMessage</span><span class="Punctuation">(</span><span class="Identifier">cert</span><span class="Operator">.</span><span class="Identifier">private</span><span class="Punctuation">,</span> <span class="StringLit">"Hello!"</span><span class="Punctuation">)</span><span class="Punctuation">)</span><span class="Punctuation">)</span><span class="Operator">.</span><span class="Identifier">isValid</span> <span class="Operator">==</span> <span class="Identifier">true</span></pre>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
<div id="verifySignature-procs-all">
|
|
<div id="verifySignature,,string">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#verifySignature%2C%2Cstring"><span class="Identifier">verifySignature</span></a><span class="Other">(</span><span class="Identifier">publicKeys</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><a href="nimPGP.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">]</span> <span class="Keyword">or</span> <a href="nimPGP.html#PublicKey"><span class="Identifier">PublicKey</span></a> <span class="Keyword">or</span>
|
|
<span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">message</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <a href="nimPGP.html#Verification"><span class="Identifier">Verification</span></a></pre></dt>
|
|
<dd>
|
|
|
|
For signing of text, see <a class="reference internal nimdoc" title="proc signMessage(privateKey: PrivateKey; message: string;
|
|
keyid: string or Subkey = ""; passwordHandler = PasswordHandler()): string" href="#signMessage,PrivateKey,string,string">signMessage</a><hr />
|
|
<p>Capable of raising the following exceptions:</p>
|
|
<p><a class="reference internal nimdoc" title="object FailedToParseKeyPublicException" href="#FailedToParseKeyPublicException">FailedToParseKeyPublicException</a>, <a class="reference internal nimdoc" title="object CertRevokedException" href="#CertRevokedException">CertRevokedException</a>, <a class="reference internal nimdoc" title="object NoKeyMeetsSelectionException" href="#NoKeyMeetsSelectionException">NoKeyMeetsSelectionException</a></p>
|
|
<p><a class="reference internal nimdoc" title="object FailedToParseMessageException" href="#FailedToParseMessageException">FailedToParseMessageException</a>, <a class="reference internal nimdoc" title="object FailedToReadFromBufferException" href="#FailedToReadFromBufferException">FailedToReadFromBufferException</a>, <a class="reference internal nimdoc" title="object PackedParserFailedToRecurseException" href="#PackedParserFailedToRecurseException">PackedParserFailedToRecurseException</a></p>
|
|
<p><a class="reference internal" href="#CertIsInvalidException">CertIsInvalidException</a></p>
|
|
|
|
<p><strong class="examples_text">Example:</strong></p>
|
|
<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">nimPGP</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">cert</span> <span class="Operator">=</span> <span class="Identifier">newCert</span><span class="Punctuation">(</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="Identifier">newSubkey</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="Identifier">ForSigning</span><span class="Punctuation">}</span><span class="Punctuation">)</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">signedMessage</span> <span class="Operator">=</span> <span class="Identifier">signMessage</span><span class="Punctuation">(</span><span class="Identifier">cert</span><span class="Operator">.</span><span class="Identifier">private</span><span class="Punctuation">,</span> <span class="StringLit">"Confidential Information"</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">echo</span> <span class="Identifier">verifySignature</span><span class="Punctuation">(</span><span class="Identifier">cert</span><span class="Operator">.</span><span class="Identifier">public</span><span class="Punctuation">,</span> <span class="Identifier">signedMessage</span><span class="Punctuation">)</span></pre>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</dl>
|
|
</div>
|
|
<div class="section" id="19">
|
|
<h1><a class="toc-backref" href="#19">Exports</a></h1>
|
|
<dl class="item">
|
|
<a href="binding.html#KeyTypes"><span class="Identifier">KeyTypes</span></a>, <a href="binding.html#ReasonForRevocation"><span class="Identifier">ReasonForRevocation</span></a>, <a href="binding.html#CryptSuites"><span class="Identifier">CryptSuites</span></a>, <a href="binding.html#RevocationStatus"><span class="Identifier">RevocationStatus</span></a>
|
|
</dl>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class="twelve-columns footer">
|
|
<span class="nim-sprite"></span>
|
|
<br>
|
|
<small style="color: var(--hint);">Made with Nim. Generated: 2024-06-29 10:25:58 UTC</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Google fonts -->
|
|
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
|
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
|
</body>
|
|
</html>
|