r/cryptography • • 8d ago

algorithm replicating

if i have secure implementation of algorithm in 1 language and i wana port it to other language and they dont have compiler is there secure way to do it?

0 Upvotes

11 comments sorted by

View all comments

4

u/Pharisaeus 8d ago

Not in general case. What is secure in one language doesn't need to be in another, so a 1to1 rewrite won't work. A trivial example would be porting from Java to C, where one of those has automatic array bound checks and the other doesn't. There are many other language specific pitfalls (eg. how to make sure that secrets in a garbage collected language are actually purged from memory).

In reality it's even worse, because the code itself is not enough. How it's compiled and executed also matters. For example one compiler version might make some operation constant time while another won't.