[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Parsing private key PK - Invalid key tag or value


Hi Jakub,

I added Andreas.

Am Do., 30. Juni 2022 um 12:42 Uhr schrieb Jakub Jelen <jjelen@xxxxxxxxxx>:
>
> On 6/30/22 07:43, Heiko Thiery wrote:
> > Hi,
> >
> > I use netopeer2 with libnetconf2 in combination with libssh and
> > mbedtls. When trying to open a SSH connection I get the following
> > message:
> >
> > [INF]: LN: Accepted a connection on 0.0.0.0:830 from 127.0.0.1:38712.
> > [INF]: SR: Session 128 (user "root", CID 38) created.
> > [2022/06/28 07:31:06.841984, 1] pki_private_key_from_base64:  Parsing
> > private key PK - Invalid key tag or value
> > [ERR]: LN: Failed to set hostkey "genkey" (/tmp/gyFsev).
> >
> > Switching to use openSSL does not show this error.
> >
> > Anyone have an explanation for this?
>
> Do you have example key with this issue?

This is what is stored in sysrepo and used later on:

<keystore xmlns="urn:ietf:params:xml:ns:yang:ietf-keystore">
  <asymmetric-keys>
    <asymmetric-key>
      <name>genkey</name>
      <algorithm>rsa2048</algorithm>
      <public-key>MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1JYPdk+1mnYnAW++NRWzS33nFe7qKSk80mr5Z0hZXhwV5g+UiSBYxosbnN8kqct8ibz1kRzQOnoeC/rCk87DLhxVCP5DCabPEPWuVH2MOegQmyxHwA7/OMZvVtPWdjk0p/Nt7mgH8jhRV0Xsx1/+lXH7zB0xw1EzmRqJ8KQjRykvXPscatz6NV/JNJlewqsS4SEOaVw71wYoEtMdb+PmUg1gNFbJEOIT9mbWRyTxnL1ZUJA1xK/D2qqXjlV9ydtiVzm3EH3aWHnoNZ/tE0qK4oLK4l1G7rimxzjF4wB5vFxZnRoN6eFNrtZ96zldMlvrsMKRmSTmp6EP9AsIZnimtwIDAQAB</public-key>
      <private-key>MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDUlg92T7WadicBb741FbNLfecV7u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pj7CyObm99PpN8o3d1wp0ArNEEP67GqLijLjmaYTWhJB44KJdVLEztbLcZ2Pn49Y9O/jVzehDGwQoh2Se6R7Jqq0aS4PalQeqr94pb7KWgtkwOmmo+8k6MSuYkCgYAWPYEEop7xfZVRu+q08JAmkvkdWSNJhRxo4r1CrHGHppwcgxCyzTRmbC9DY2rkXKu3TA7mcDXTryMufFAhZnbrF90SVzwqT43aDhsywk2qi12OfhRcYVOXhzMt8gEiGrxE/KZfcmYTZydfCNrqXbNoiG3Sx1odqYa4Yak//aYPwQKBgQDk5ePk+nvbrVZu2BAq+6gGhywkL4J50Q+QWJc9v/xwXg5h7Aewmp5Qq+nQBdvjjk59tjRjopNDuLbACRrJ7L0MmnQ9ZW//bgMP1srqw0JxRWY49G2OfQDlW5qsEl7yxc+J18quQVm/u3NgcC7hpinwGGKBOrQByvYzKjvSGEuj6w==</private-key>
    </asymmetric-key>
  </asymmetric-keys>
</keystore>

Is this enough for you to check?

>
> I think the mbedtls and gcrypt did not have PEM parser or there were
> some limitations.
>
> It might also be that the openssl you are using is generating keys with
> some specific functionality that is not supported by mbedtls parser.
>
> Regards,
> --
> Jakub Jelen
> Crypto Team, Security Engineering
> Red Hat, Inc.
>
>

-- 
Heiko

References:
Parsing private key PK - Invalid key tag or valueHeiko Thiery <heiko.thiery@xxxxxxxxx>
Re: Parsing private key PK - Invalid key tag or valueJakub Jelen <jjelen@xxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org