I want to do something really basic but I need to be sure that the process is safe :
Alice and Bob have to agree on a secret 6 digits PIN. They each have a pre-shared aes symetric key k and a AES-128 block cipher. The PIN will then be used only once secretly.
I want to take care of Man-in-the-Middle.
- Alice creates à 128 bits random number :
- She encrypts
Arandwith basic ECB(
Arand, k) and gets
- Again, She encrypts
Acipher, k), as a MAC, and gets
- Alice sends to Bob
Bob does the same and sends
Bcipher|Bmac to Alice
The two of them verify the Mac by encrypting
[A|B]cipherand comparing it to
If the mac is ok, they uncipher
[A|B]cipherand get the
[A|B]randof the other.
They compute the 6 digits PIN by taking 3 digits in Arand and 3 in Brand.
Is it safe to use ECB mode in this particular case ? Is it safe to use the same key for encryption and for the mac in this case ? Is there a much easier solution to only agree on 6 digits ?
my answer is : as we use fixed size one-bloc long messages, it’s ok am i right ?
I know we should’nt imagine ourself our own algorithms but this one seems really trivial.
Thanks ! Louis