Thank,

You're the best, now it works fine. That message from the ChatGPT was the
key.

Best Regards
Petr

Documentation:
Wireguard API "wireguard_interface_create" message with private/public key
must be sent in right decoded values. Keys (string) generated from "wg
keygen" command cannot be directly converted to []byte, must be decoded.
For Go is the key function - the result is []byte[32].

> sEnc, err := 
> base64.StdEncoding.DecodeString(cfgWireguardInterface.Cfg.PrivateKey)
>
>
čt 8. 12. 2022 v 11:26 odesílatel Pim van Pelt via lists.fd.io <pim=
ipng...@lists.fd.io> napsal:

> Hoi Petr,
>
> I think that the keys in the wireguard plugin are represented
> as bytestream, and your 44 character string probably refers to its base64
> representation. Try sending the raw key (32 bytes).
>
> As an aside, I thought I'd ask ChatGPT this question, because I thought it
> was a fun puzzle.
>
> Pim: if I have a 32 byte array and want to print that as a base64 encoded
>> string, how long would the string be ?
>> ChatGPT: If you have a 32-byte array and you want to print it as a
>> base64-encoded string, the resulting string would be 44 characters long.
>> This is because base64 encoding takes 3 bytes of data and converts it into
>> 4 characters, so 32 bytes of data would be encoded as 43.3 characters,
>> which would be rounded up to 44 characters.
>
>
> groet,
> Pim
>
>
> On Thu, Dec 8, 2022 at 7:45 AM Petr Boltík <petr.bol...@gmail.com> wrote:
>
>> Hi all,
>>
>> I have an issue with wireguard api message wireguard_interface_create.
>> The public/private key is statically declared as "u8 public_key[32]", but
>> the length of the public/private key is 44 (at this moment).
>> Api wireguard_interface_dump is also impacted. Cli works fine - there is
>> "u8 private_key" dynamic assignment. I have already tried to increase
>> "typedef wireguard_interface", but this simple modification is not correct
>> (I'm not familiar with C).
>>
>> Please forward this message to the right people.
>>
>> Thanks to all
>> Petr
>>
>>
>>
>>
>
> --
> Pim van Pelt <p...@ipng.nl>
> PBVP1-RIPE - http://www.ipng.nl/
>
> 
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#22304): https://lists.fd.io/g/vpp-dev/message/22304
Mute This Topic: https://lists.fd.io/mt/95533324/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/leave/1480452/21656/631435203/xyzzy 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to