Skip to content

RNG in no_std #150

Description

@xFranv8

Hello,

I am trying to connect to a Mqtt broker with TLS from my rp pico with rust.

let mut rng = RoscRng;
let mut tls_connection: TlsConnection<_, Aes256GcmSha384> =
        TlsConnection::new(tcp_socket, &mut record_read_buf, &mut record_write_buf);

  tls_connection
      .open(TlsContext::new(
          &tls_config,
          UnsecureProvider::new::<Aes256GcmSha384>(rng),
      ))
      .await
      .unwrap();

I am using

use embassy_rp::clocks::RoscRng;
use rand::RngCore;

But receive the following error:

error[E0277]: the trait bound `RoscRng: CryptoRng` is not satisfied
   --> src/main.rs:177:5
    |
177 | /     tls_connection
178 | |         .open(TlsContext::new(
179 | |             &tls_config,
180 | |             UnsecureProvider::new::<Aes256GcmSha384>(rng),
181 | |         ))
    | |__________^ the trait `CryptoRng` is not implemented for `RoscRng`
    |
    = help: the following other types implement trait `CryptoRng`:
              &'a mut R
              rand_core::block::BlockRng<R>
    = note: required for `RoscRng` to implement `CryptoRngCore`
    = note: required for `UnsecureProvider<Aes256GcmSha384, RoscRng>` to implement `CryptoProvider`
note: required by a bound in `embedded_tls::TlsConnection::<'a, Socket, CipherSuite>::open`
   --> /Users/xfranv8/.cargo/git/checkouts/embedded-tls-6ca93bdfa1e2460b/7936bc1/src/asynch.rs:78:19
    |
73  |     pub async fn open<'v, Provider>(
    |                  ---- required by a bound in this associated function
...
78  |         Provider: CryptoProvider<CipherSuite = CipherSuite>,
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `TlsConnection::<'a, Socket, CipherSuite>::open`

Any help you could provide?

Thanks!!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions