<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hi,</p>
<p>I am playing around with GPG which I'd like to use to sign
message and use the resulting signature binary in another piece of
code.<br>
</p>
<p>So far I have created a simple PGP packet parser in JuliaLang
with which I think I can successfully extract the elliptic curve
point representing the public key as follows. See <a
moz-do-not-send="true"
href="https://gitlab.com/braneproject/PGParser.jl">GitLab</a>
for source code.<br>
</p>
<p>```<br>
$ gpg --output pubkey.bin --export 8FAB2B40D753C0F6<br>
```</p>
```
<p>julia> packets = bin2packet("pubkey.bin")<br>
3-element Array{PGPPacket,1}:<br>
Public-Key Packet<br>
Length : 79, Partial : false<br>
PublicKey(0x04, 1550079457, scep256k1 Point(𝑥,𝑦):<br>
f05314566c9bfc8d8cf463a7a01e7735245d588a60dd874f09a9636620abb314,<br>
6bda245d43cbbe019ab1ad74316d675dd858cdd776820969bcc21bbccbd3a661)<br>
```</p>
<p>I am then generating a message within Julia, an integer, which
needs to be signed and which I just save to file made of 32 bytes
representing the 256 bits number in big-endian. <br>
</p>
<p>But I wonder if this should be serialized in some way? Should
their be a package header indicating to GPG what it is signing
for, what length is has or anything else? Should I maybe follow
X.690 for integer encoding? <br>
</p>
<p><br>
</p>
<p>Next, comes signature parsing which I haven't been able to
interpret so far, finding no hints in RFC4880 or 5480.
Nevertheless, I assume the last 68 bytes must be signature
representation with two integer, preceded by some bytes which
looks to be 00ff in the below message.</p>
<p>How should EC signature be parsed exactly? Where would this be
documented?<br>
Last but not least, is the signature hashed? And if yes, is there
a way to get it unhashed?<br>
</p>
<p><br>
</p>
<p>```</p>
<p>julia> z =
99621552382283238930643867389539606415724582999531180113553721867524305282175;<br>
julia> f = open("z.bin","w");<br>
julia> write(f,int2bytes(z))<br>
32</p>
<p>```</p>
<p>```<br>
</p>
<p>$ gpg -b -u D753C0F6 z.bin</p>
<p>```</p>
<p>```<br>
julia> packet = bin2packet("z.bin.sig")<br>
1-element Array{PGPPacket,1}:<br>
Signature Packet<br>
Length : 117, Partial : false<br>
Version : 4<br>
Type : SHA256<br>
SignatureSubPacket[<br>
Issuer Fingerprint<br>
041f6132045b4b6c393c48846e8fab2b40d753c0f6, <br>
Signature Creation Time<br>
5c70346a]<br>
SignatureSubPacket[<br>
Issuer<br>
8fab2b40d753c0f6]<br>
Hash left : 3462<br>
scep256k1 signature(𝑟, 𝑠):
"00ff6ae576da68ddbd1a2aff20d450186fdd1a13bbbddc1b9837a19080364f3cd83700ff4727b504b86d667b048147c939b4eafae21203e1235ae6e68aa71477292ea173"</p>
<p>```</p>
<p>All my attempt to verify signature of message provided pub key
have so far failed and so there is clearly something I do not get.
I am looking forward at receiving any tips :)</p>
<p><br>
</p>
<p>Thanks upfront<br>
</p>
</body>
</html>