2
0

C API for hybrid passwords.

This commit is contained in:
Maarten Billemont
2017-08-04 10:43:46 -04:00
parent d6415277d0
commit 228f8e4ed1
7 changed files with 115 additions and 15 deletions

View File

@@ -84,3 +84,45 @@ const char *mpw_sitePassword(
return NULL;
}
}
const char *mpw_encrypt(
MPMasterKey masterKey, const char *plainText, const MPAlgorithmVersion algorithmVersion) {
if (!masterKey || !plainText)
return NULL;
switch (algorithmVersion) {
case MPAlgorithmVersion0:
return mpw_encrypt_v0( masterKey, plainText );
case MPAlgorithmVersion1:
return mpw_encrypt_v1( masterKey, plainText );
case MPAlgorithmVersion2:
return mpw_encrypt_v2( masterKey, plainText );
case MPAlgorithmVersion3:
return mpw_encrypt_v3( masterKey, plainText );
default:
err( "Unsupported version: %d\n", algorithmVersion );
return NULL;
}
}
const char *mpw_decrypt(
MPMasterKey masterKey, const char *cipherText, const MPAlgorithmVersion algorithmVersion) {
if (!masterKey || !cipherText)
return NULL;
switch (algorithmVersion) {
case MPAlgorithmVersion0:
return mpw_decrypt_v0( masterKey, cipherText );
case MPAlgorithmVersion1:
return mpw_decrypt_v1( masterKey, cipherText );
case MPAlgorithmVersion2:
return mpw_decrypt_v2( masterKey, cipherText );
case MPAlgorithmVersion3:
return mpw_decrypt_v3( masterKey, cipherText );
default:
err( "Unsupported version: %d\n", algorithmVersion );
return NULL;
}
}