Support for unset login type.
This commit is contained in:
parent
94a6c925bc
commit
88a4d7ba4d
@ -122,7 +122,10 @@ const char *mpw_site_result(
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resultType & MPResultTypeClassTemplate) {
|
if (resultType == MPResultTypeNone) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else if (resultType & MPResultTypeClassTemplate) {
|
||||||
switch (algorithmVersion) {
|
switch (algorithmVersion) {
|
||||||
case MPAlgorithmVersionV0:
|
case MPAlgorithmVersionV0:
|
||||||
return mpw_site_template_password_v0( masterKey, siteKey, resultType, resultParam );
|
return mpw_site_template_password_v0( masterKey, siteKey, resultType, resultParam );
|
||||||
@ -203,6 +206,10 @@ const char *mpw_site_state(
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (resultType == MPResultTypeNone) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
switch (algorithmVersion) {
|
switch (algorithmVersion) {
|
||||||
case MPAlgorithmVersionV0:
|
case MPAlgorithmVersionV0:
|
||||||
return mpw_site_state_v0( masterKey, siteKey, resultType, resultParam );
|
return mpw_site_state_v0( masterKey, siteKey, resultType, resultParam );
|
||||||
|
@ -93,7 +93,7 @@ MPMarshalledUser *mpw_marshal_user(
|
|||||||
.fullName = mpw_strdup( fullName ),
|
.fullName = mpw_strdup( fullName ),
|
||||||
.identicon = MPIdenticonUnset,
|
.identicon = MPIdenticonUnset,
|
||||||
.keyID = NULL,
|
.keyID = NULL,
|
||||||
.defaultType = MPResultTypeDefault,
|
.defaultType = MPResultTypeDefaultResult,
|
||||||
.lastUsed = 0,
|
.lastUsed = 0,
|
||||||
|
|
||||||
.sites_count = 0,
|
.sites_count = 0,
|
||||||
@ -122,7 +122,7 @@ MPMarshalledSite *mpw_marshal_site(
|
|||||||
.resultType = resultType,
|
.resultType = resultType,
|
||||||
.resultState = NULL,
|
.resultState = NULL,
|
||||||
|
|
||||||
.loginType = MPResultTypeTemplateName,
|
.loginType = MPResultTypeDefaultLogin,
|
||||||
.loginState = NULL,
|
.loginState = NULL,
|
||||||
|
|
||||||
.url = NULL,
|
.url = NULL,
|
||||||
@ -864,7 +864,7 @@ static void mpw_marshal_read_flat(
|
|||||||
char *fullName = NULL, *keyID = NULL;
|
char *fullName = NULL, *keyID = NULL;
|
||||||
MPAlgorithmVersion algorithm = MPAlgorithmVersionCurrent;
|
MPAlgorithmVersion algorithm = MPAlgorithmVersionCurrent;
|
||||||
MPIdenticon identicon = MPIdenticonUnset;
|
MPIdenticon identicon = MPIdenticonUnset;
|
||||||
MPResultType defaultType = MPResultTypeDefault;
|
MPResultType defaultType = MPResultTypeDefaultResult;
|
||||||
time_t exportDate = 0;
|
time_t exportDate = 0;
|
||||||
bool headerStarted = false, headerEnded = false, importRedacted = false;
|
bool headerStarted = false, headerEnded = false, importRedacted = false;
|
||||||
for (const char *endOfLine, *positionInLine = in; (endOfLine = strstr( positionInLine, "\n" )); positionInLine = endOfLine + 1) {
|
for (const char *endOfLine, *positionInLine = in; (endOfLine = strstr( positionInLine, "\n" )); positionInLine = endOfLine + 1) {
|
||||||
@ -1014,13 +1014,14 @@ static void mpw_marshal_read_flat(
|
|||||||
mpw_marshal_error( file, MPMarshalErrorIllegal, "Invalid site last used: %s: %s", siteName, str_lastUsed );
|
mpw_marshal_error( file, MPMarshalErrorIllegal, "Invalid site last used: %s: %s", siteName, str_lastUsed );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
MPResultType siteLoginType = siteLoginState && strlen( siteLoginState )? MPResultTypeStatefulPersonal: MPResultTypeNone;
|
||||||
|
|
||||||
char dateString[21];
|
char dateString[21];
|
||||||
mpw_marshal_data_set_num( siteCounter, file->data, "sites", siteName, "counter", NULL );
|
mpw_marshal_data_set_num( siteCounter, file->data, "sites", siteName, "counter", NULL );
|
||||||
mpw_marshal_data_set_num( siteAlgorithm, file->data, "sites", siteName, "algorithm", NULL );
|
mpw_marshal_data_set_num( siteAlgorithm, file->data, "sites", siteName, "algorithm", NULL );
|
||||||
mpw_marshal_data_set_num( siteType, file->data, "sites", siteName, "type", NULL );
|
mpw_marshal_data_set_num( siteType, file->data, "sites", siteName, "type", NULL );
|
||||||
mpw_marshal_data_set_str( siteResultState, file->data, "sites", siteName, "password", NULL );
|
mpw_marshal_data_set_str( siteResultState, file->data, "sites", siteName, "password", NULL );
|
||||||
mpw_marshal_data_set_num( MPResultTypeDefault, file->data, "sites", siteName, "login_type", NULL );
|
mpw_marshal_data_set_num( siteLoginType, file->data, "sites", siteName, "login_type", NULL );
|
||||||
mpw_marshal_data_set_str( siteLoginState, file->data, "sites", siteName, "login_name", NULL );
|
mpw_marshal_data_set_str( siteLoginState, file->data, "sites", siteName, "login_name", NULL );
|
||||||
mpw_marshal_data_set_num( strtol( str_uses, NULL, 10 ), file->data, "sites", siteName, "uses", NULL );
|
mpw_marshal_data_set_num( strtol( str_uses, NULL, 10 ), file->data, "sites", siteName, "uses", NULL );
|
||||||
if (strftime( dateString, sizeof( dateString ), "%FT%TZ", gmtime( &siteLastUsed ) ))
|
if (strftime( dateString, sizeof( dateString ), "%FT%TZ", gmtime( &siteLastUsed ) ))
|
||||||
@ -1150,7 +1151,7 @@ MPMarshalledUser *mpw_marshal_auth(
|
|||||||
}
|
}
|
||||||
MPIdenticon identicon = mpw_identicon_encoded( mpw_marshal_data_get_str( file->data, "user", "identicon", NULL ) );
|
MPIdenticon identicon = mpw_identicon_encoded( mpw_marshal_data_get_str( file->data, "user", "identicon", NULL ) );
|
||||||
const char *keyID = mpw_marshal_data_get_str( file->data, "user", "key_id", NULL );
|
const char *keyID = mpw_marshal_data_get_str( file->data, "user", "key_id", NULL );
|
||||||
MPResultType defaultType = mpw_default_n( MPResultTypeDefault, mpw_marshal_data_get_num( file->data, "user", "default_type", NULL ) );
|
MPResultType defaultType = mpw_default_n( MPResultTypeDefaultResult, mpw_marshal_data_get_num( file->data, "user", "default_type", NULL ) );
|
||||||
if (!mpw_type_short_name( defaultType )) {
|
if (!mpw_type_short_name( defaultType )) {
|
||||||
mpw_marshal_error( file, MPMarshalErrorIllegal, "Invalid user default type: %u", defaultType );
|
mpw_marshal_error( file, MPMarshalErrorIllegal, "Invalid user default type: %u", defaultType );
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1216,7 +1217,7 @@ MPMarshalledUser *mpw_marshal_auth(
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
const char *siteResultState = mpw_marshal_data_get_str( siteData, "password", NULL );
|
const char *siteResultState = mpw_marshal_data_get_str( siteData, "password", NULL );
|
||||||
MPResultType siteLoginType = mpw_default_n( MPResultTypeTemplateName, mpw_marshal_data_get_num( siteData, "login_type", NULL ) );
|
MPResultType siteLoginType = mpw_default_n( MPResultTypeDefaultLogin, mpw_marshal_data_get_num( siteData, "login_type", NULL ) );
|
||||||
if (!mpw_type_short_name( siteLoginType )) {
|
if (!mpw_type_short_name( siteLoginType )) {
|
||||||
mpw_marshal_error( file, MPMarshalErrorIllegal, "Invalid site login type: %s: %u", siteName, siteLoginType );
|
mpw_marshal_error( file, MPMarshalErrorIllegal, "Invalid site login type: %s: %u", siteName, siteLoginType );
|
||||||
mpw_free( &masterKey, MPMasterKeySize );
|
mpw_free( &masterKey, MPMasterKeySize );
|
||||||
@ -1258,10 +1259,10 @@ MPMarshalledUser *mpw_marshal_auth(
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (siteResultState && strlen( siteResultState ))
|
if (siteResultState && strlen( siteResultState ) && masterKey)
|
||||||
site->resultState = mpw_site_state( masterKey, site->siteName, site->counter,
|
site->resultState = mpw_site_state( masterKey, site->siteName, site->counter,
|
||||||
MPKeyPurposeAuthentication, NULL, site->resultType, siteResultState, site->algorithm );
|
MPKeyPurposeAuthentication, NULL, site->resultType, siteResultState, site->algorithm );
|
||||||
if (siteLoginState && strlen( siteLoginState ))
|
if (siteLoginState && strlen( siteLoginState ) && masterKey)
|
||||||
site->loginState = mpw_site_state( masterKey, site->siteName, MPCounterValueInitial,
|
site->loginState = mpw_site_state( masterKey, site->siteName, MPCounterValueInitial,
|
||||||
MPKeyPurposeIdentification, NULL, site->loginType, siteLoginState, site->algorithm );
|
MPKeyPurposeIdentification, NULL, site->loginType, siteLoginState, site->algorithm );
|
||||||
}
|
}
|
||||||
@ -1282,7 +1283,7 @@ MPMarshalledUser *mpw_marshal_auth(
|
|||||||
|
|
||||||
if (!user->redacted) {
|
if (!user->redacted) {
|
||||||
// Clear Text
|
// Clear Text
|
||||||
if (answerState && strlen( answerState ))
|
if (answerState && strlen( answerState ) && masterKey)
|
||||||
question->state = mpw_site_state( masterKey, site->siteName, MPCounterValueInitial,
|
question->state = mpw_site_state( masterKey, site->siteName, MPCounterValueInitial,
|
||||||
MPKeyPurposeRecovery, question->keyword, question->type, answerState, site->algorithm );
|
MPKeyPurposeRecovery, question->keyword, question->type, answerState, site->algorithm );
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,8 @@ const MPResultType mpw_type_named(const char *typeName) {
|
|||||||
|
|
||||||
// Find what password type is represented by the type letter.
|
// Find what password type is represented by the type letter.
|
||||||
if (strlen( typeName ) == 1) {
|
if (strlen( typeName ) == 1) {
|
||||||
|
if ('0' == typeName[0])
|
||||||
|
return MPResultTypeNone;
|
||||||
if ('x' == typeName[0])
|
if ('x' == typeName[0])
|
||||||
return MPResultTypeTemplateMaximum;
|
return MPResultTypeTemplateMaximum;
|
||||||
if ('l' == typeName[0])
|
if ('l' == typeName[0])
|
||||||
@ -63,6 +65,8 @@ const MPResultType mpw_type_named(const char *typeName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find what password type is represented by the type name.
|
// Find what password type is represented by the type name.
|
||||||
|
if (mpw_strncasecmp( mpw_type_short_name( MPResultTypeNone ), typeName, strlen( typeName ) ) == OK)
|
||||||
|
return MPResultTypeNone;
|
||||||
if (mpw_strncasecmp( mpw_type_short_name( MPResultTypeTemplateMaximum ), typeName, strlen( typeName ) ) == OK)
|
if (mpw_strncasecmp( mpw_type_short_name( MPResultTypeTemplateMaximum ), typeName, strlen( typeName ) ) == OK)
|
||||||
return MPResultTypeTemplateMaximum;
|
return MPResultTypeTemplateMaximum;
|
||||||
if (mpw_strncasecmp( mpw_type_short_name( MPResultTypeTemplateLong ), typeName, strlen( typeName ) ) == OK)
|
if (mpw_strncasecmp( mpw_type_short_name( MPResultTypeTemplateLong ), typeName, strlen( typeName ) ) == OK)
|
||||||
@ -93,6 +97,8 @@ const MPResultType mpw_type_named(const char *typeName) {
|
|||||||
const char *mpw_type_abbreviation(const MPResultType resultType) {
|
const char *mpw_type_abbreviation(const MPResultType resultType) {
|
||||||
|
|
||||||
switch (resultType) {
|
switch (resultType) {
|
||||||
|
case MPResultTypeNone:
|
||||||
|
return "no";
|
||||||
case MPResultTypeTemplateMaximum:
|
case MPResultTypeTemplateMaximum:
|
||||||
return "max";
|
return "max";
|
||||||
case MPResultTypeTemplateLong:
|
case MPResultTypeTemplateLong:
|
||||||
@ -125,6 +131,8 @@ const char *mpw_type_abbreviation(const MPResultType resultType) {
|
|||||||
const char *mpw_type_short_name(const MPResultType resultType) {
|
const char *mpw_type_short_name(const MPResultType resultType) {
|
||||||
|
|
||||||
switch (resultType) {
|
switch (resultType) {
|
||||||
|
case MPResultTypeNone:
|
||||||
|
return "none";
|
||||||
case MPResultTypeTemplateMaximum:
|
case MPResultTypeTemplateMaximum:
|
||||||
return "maximum";
|
return "maximum";
|
||||||
case MPResultTypeTemplateLong:
|
case MPResultTypeTemplateLong:
|
||||||
@ -157,6 +165,8 @@ const char *mpw_type_short_name(const MPResultType resultType) {
|
|||||||
const char *mpw_type_long_name(const MPResultType resultType) {
|
const char *mpw_type_long_name(const MPResultType resultType) {
|
||||||
|
|
||||||
switch (resultType) {
|
switch (resultType) {
|
||||||
|
case MPResultTypeNone:
|
||||||
|
return "None";
|
||||||
case MPResultTypeTemplateMaximum:
|
case MPResultTypeTemplateMaximum:
|
||||||
return "Maximum Security Password";
|
return "Maximum Security Password";
|
||||||
case MPResultTypeTemplateLong:
|
case MPResultTypeTemplateLong:
|
||||||
|
@ -80,6 +80,9 @@ typedef mpw_opts( uint16_t, MPSiteFeature ) {
|
|||||||
|
|
||||||
// bit 0-3 | MPResultTypeClass | MPSiteFeature
|
// bit 0-3 | MPResultTypeClass | MPSiteFeature
|
||||||
typedef mpw_enum( uint32_t, MPResultType ) {
|
typedef mpw_enum( uint32_t, MPResultType ) {
|
||||||
|
/** 0: Don't produce a result */
|
||||||
|
MPResultTypeNone = 0,
|
||||||
|
|
||||||
/** 16: pg^VMAUBk5x3p%HP%i4= */
|
/** 16: pg^VMAUBk5x3p%HP%i4= */
|
||||||
MPResultTypeTemplateMaximum = 0x0 | MPResultTypeClassTemplate | 0x0,
|
MPResultTypeTemplateMaximum = 0x0 | MPResultTypeClassTemplate | 0x0,
|
||||||
/** 17: BiroYena8:Kixa */
|
/** 17: BiroYena8:Kixa */
|
||||||
@ -105,7 +108,8 @@ typedef mpw_enum( uint32_t, MPResultType ) {
|
|||||||
/** 4160: Derive a unique binary key. */
|
/** 4160: Derive a unique binary key. */
|
||||||
MPResultTypeDeriveKey = 0x0 | MPResultTypeClassDerive | MPSiteFeatureAlternative,
|
MPResultTypeDeriveKey = 0x0 | MPResultTypeClassDerive | MPSiteFeatureAlternative,
|
||||||
|
|
||||||
MPResultTypeDefault = MPResultTypeTemplateLong,
|
MPResultTypeDefaultResult = MPResultTypeTemplateLong,
|
||||||
|
MPResultTypeDefaultLogin = MPResultTypeTemplateName,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef mpw_enum ( uint32_t, MPCounterValue ) {
|
typedef mpw_enum ( uint32_t, MPCounterValue ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user