e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen * OTP password scheme.
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen * Copyright (c) 2006 Andrey Panin <pazke@donpac.ru>
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen * This software is released under the MIT license.
a10ed8c47534b4c6b6bf2711ccfe577e720a47b4Timo Sirainenint password_generate_otp(const char *pw, const char *state_data,
a10ed8c47534b4c6b6bf2711ccfe577e720a47b4Timo Sirainen if (otp_parse_dbentry(state_data, &state) != 0)
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen /* Generate new OTP credentials from plaintext */
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen unsigned char random_data[OTP_MAX_SEED_LEN / 2];
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen random_fill(random_data, sizeof(random_data));
e34d170f8f0e084bd94bfbc1a7085ece67e508dfTimo Sirainen random_hex = binary_to_hex(random_data, sizeof(random_data));
e34d170f8f0e084bd94bfbc1a7085ece67e508dfTimo Sirainen if (i_strocpy(state.seed, random_hex, sizeof(state.seed)) < 0)