I am going to ask a rather stupid question for which I apologize in advance, but I'm sort of losing my head at this point.
I am working on an encryption system where two parties are required to authenticate themselves to one another and subsequently perform a key exchange.
The procedure is as follows:
1. Assume Alice and Bob both generate a secret one-time token.
2. Alice generates an ephemeral key pair and signs the token with her private key.
3. Alice sends the signature over to Bob along with her public key.
4. Bob verifies the signature and can now trust Alice's public key.
Now let's say a malicious actor, Charlie wants to authenticate his public key to Bob, and Charlie has managed to intercept the signature sent by Alice.
Can Charlie destroy Alice's original signature, sign the token with his own key, and "replay" it to Bob?
If this is possible, how can one avoid such a situation?
Edit: So it turns out there's a term for exactly what I was trying to achieve, called PAKE. Thanks to u/cryptoam1, u/Natanael_L, and u/djao for pointing it out, and sorry for asking a question without first doing thorough research, but I ended up learning something new. Reddit goated as always!