WIP - remove dependency on ciphers.plist.
This commit is contained in:
parent
339ef8d1bc
commit
773058da78
2
External/Pearl
vendored
2
External/Pearl
vendored
@ -1 +1 @@
|
|||||||
Subproject commit daa260b3ecaca266ffcfa597e9350900dda6cc56
|
Subproject commit 0e9484b6512150fbbfffdddcdec62f8e9a741254
|
@ -1,2 +1,3 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash -e
|
||||||
gcc -I"lib/scrypt/lib" -I"lib/scrypt/libcperciva" -I"lib/proplib/include" -l "crypto_aesctr.o" -l "sha256.o" -l "crypto_scrypt-nosse.o" -l "memlimit.o" -l "scryptenc_cpuperf.o" -l"scryptenc.o" -l"crypto" -l"prop" -L"lib/scrypt" -L"lib/proplib/src/.libs" mpw.c -o mpw
|
gcc types.c -o types.o
|
||||||
|
gcc -I"lib/scrypt/lib" -I"lib/scrypt/libcperciva" -l "crypto_aesctr.o" -l "sha256.o" -l "crypto_scrypt-nosse.o" -l "memlimit.o" -l "scryptenc_cpuperf.o" -l"scryptenc.o" -l"types.o" -l"crypto" -L"lib/scrypt" mpw.c -o mpw
|
||||||
|
78
MasterPassword/C/ciphers
Normal file
78
MasterPassword/C/ciphers
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>MPElementGeneratedEntity</key>
|
||||||
|
<dict>
|
||||||
|
<key>Maximum Security Password</key>
|
||||||
|
<array>
|
||||||
|
<string>anoxxxxxxxxxxxxxxxxx</string>
|
||||||
|
<string>axxxxxxxxxxxxxxxxxno</string>
|
||||||
|
</array>
|
||||||
|
<key>Long Password</key>
|
||||||
|
<array>
|
||||||
|
<string>CvcvnoCvcvCvcv</string>
|
||||||
|
<string>CvcvCvcvnoCvcv</string>
|
||||||
|
<string>CvcvCvcvCvcvno</string>
|
||||||
|
<string>CvccnoCvcvCvcv</string>
|
||||||
|
<string>CvccCvcvnoCvcv</string>
|
||||||
|
<string>CvccCvcvCvcvno</string>
|
||||||
|
<string>CvcvnoCvccCvcv</string>
|
||||||
|
<string>CvcvCvccnoCvcv</string>
|
||||||
|
<string>CvcvCvccCvcvno</string>
|
||||||
|
<string>CvcvnoCvcvCvcc</string>
|
||||||
|
<string>CvcvCvcvnoCvcc</string>
|
||||||
|
<string>CvcvCvcvCvccno</string>
|
||||||
|
<string>CvccnoCvccCvcv</string>
|
||||||
|
<string>CvccCvccnoCvcv</string>
|
||||||
|
<string>CvccCvccCvcvno</string>
|
||||||
|
<string>CvcvnoCvccCvcc</string>
|
||||||
|
<string>CvcvCvccnoCvcc</string>
|
||||||
|
<string>CvcvCvccCvccno</string>
|
||||||
|
<string>CvccnoCvcvCvcc</string>
|
||||||
|
<string>CvccCvcvnoCvcc</string>
|
||||||
|
<string>CvccCvcvCvccno</string>
|
||||||
|
</array>
|
||||||
|
<key>Medium Password</key>
|
||||||
|
<array>
|
||||||
|
<string>CvcnoCvc</string>
|
||||||
|
<string>CvcCvcno</string>
|
||||||
|
</array>
|
||||||
|
<key>Basic Password</key>
|
||||||
|
<array>
|
||||||
|
<string>aaanaaan</string>
|
||||||
|
<string>aannaaan</string>
|
||||||
|
<string>aaannaaa</string>
|
||||||
|
</array>
|
||||||
|
<key>Short Password</key>
|
||||||
|
<array>
|
||||||
|
<string>Cvcn</string>
|
||||||
|
</array>
|
||||||
|
<key>PIN</key>
|
||||||
|
<array>
|
||||||
|
<string>nnnn</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
<key>MPCharacterClasses</key>
|
||||||
|
<dict>
|
||||||
|
<key>V</key>
|
||||||
|
<string>AEIOU</string>
|
||||||
|
<key>C</key>
|
||||||
|
<string>BCDFGHJKLMNPQRSTVWXYZ</string>
|
||||||
|
<key>v</key>
|
||||||
|
<string>aeiou</string>
|
||||||
|
<key>c</key>
|
||||||
|
<string>bcdfghjklmnpqrstvwxyz</string>
|
||||||
|
<key>A</key>
|
||||||
|
<string>AEIOUBCDFGHJKLMNPQRSTVWXYZ</string>
|
||||||
|
<key>a</key>
|
||||||
|
<string>AEIOUaeiouBCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz</string>
|
||||||
|
<key>n</key>
|
||||||
|
<string>0123456789</string>
|
||||||
|
<key>o</key>
|
||||||
|
<string>@&%?,=[]_:-+*$#!'^~;()/.</string>
|
||||||
|
<key>x</key>
|
||||||
|
<string>AEIOUaeiouBCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz0123456789!@#$%^&*()</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
@ -1 +0,0 @@
|
|||||||
../Resources/Data/ciphers.plist
|
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include <alg/sha256.h>
|
#include <alg/sha256.h>
|
||||||
#include <crypto/crypto_scrypt.h>
|
#include <crypto/crypto_scrypt.h>
|
||||||
#include <prop/proplib.h>
|
#include "types.h"
|
||||||
|
|
||||||
#define MP_N 32768
|
#define MP_N 32768
|
||||||
#define MP_r 8
|
#define MP_r 8
|
||||||
@ -178,38 +178,15 @@ int main(int argc, char *const argv[]) {
|
|||||||
free(sitePasswordInfo);
|
free(sitePasswordInfo);
|
||||||
|
|
||||||
// Determine the cipher.
|
// Determine the cipher.
|
||||||
prop_dictionary_t MPTypes_ciphers = prop_dictionary_internalize_from_file("ciphers.plist");
|
const char *cipher = CipherForType(siteType, sitePasswordSeed);
|
||||||
if (!MPTypes_ciphers) {
|
|
||||||
fprintf (stderr, "Could not read cipher definitions: %d\n", errno);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
prop_array_t typeCiphers = prop_dictionary_get(prop_dictionary_get(MPTypes_ciphers, "[self classNameOfType:type]"), "[self nameOfType:type]");
|
|
||||||
if (!typeCiphers) {
|
|
||||||
fprintf (stderr, "Could not find cipher definition for type: %s\n", siteTypeString);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
prop_string_t cipher = prop_array_get(typeCiphers, sitePasswordSeed[0] % prop_array_count(typeCiphers));
|
|
||||||
if (!typeCiphers) {
|
|
||||||
fprintf (stderr, "Missing cipher definitions for type: %s\n", siteTypeString);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
//trc(@"type %@, ciphers: %@, selected: %@", [self nameOfType:type], typeCiphers, cipher);
|
//trc(@"type %@, ciphers: %@, selected: %@", [self nameOfType:type], typeCiphers, cipher);
|
||||||
|
|
||||||
// Encode the password from the seed using the cipher.
|
// Encode the password from the seed using the cipher.
|
||||||
//NSAssert([seed length] >= [cipher length] + 1, @"Insufficient seed bytes to encode cipher.");
|
//NSAssert([seed length] >= [cipher length] + 1, @"Insufficient seed bytes to encode cipher.");
|
||||||
const prop_dictionary_t characterClasses = prop_dictionary_get(MPTypes_ciphers, "MPCharacterClasses");
|
char *sitePassword = calloc(strlen(cipher) + 1, sizeof(char));
|
||||||
char *sitePassword = calloc(prop_string_size(cipher) + 1, sizeof(char));
|
for (int c = 0; c < strlen(cipher); ++c)
|
||||||
char cipherClass[2] = {0, 0};
|
|
||||||
for (int c = 0; c < prop_string_size(cipher); ++c) {
|
|
||||||
|
|
||||||
const uint16_t keyByte = sitePasswordSeed[c + 1];
|
|
||||||
cipherClass[0] = prop_string_cstring_nocopy(cipher)[c];
|
|
||||||
const prop_string_t cipherClassCharacters = prop_dictionary_get(characterClasses, cipherClass);
|
|
||||||
const char character = prop_string_cstring_nocopy(cipherClassCharacters)[ keyByte % prop_string_size(cipherClassCharacters) ];
|
|
||||||
|
|
||||||
//trc(@"class %@ has characters: %@, index: %u, selected: %@", cipherClass, cipherClassCharacters, keyByte, character);
|
//trc(@"class %@ has characters: %@, index: %u, selected: %@", cipherClass, cipherClassCharacters, keyByte, character);
|
||||||
sitePassword[c] = character;
|
sitePassword[c] = CharacterFromClass(cipher[c], sitePasswordSeed[c + 1]);
|
||||||
}
|
|
||||||
memset(sitePasswordSeed, 0, sizeof(sitePasswordSeed));
|
memset(sitePasswordSeed, 0, sizeof(sitePasswordSeed));
|
||||||
|
|
||||||
// Output the password.
|
// Output the password.
|
||||||
|
63
MasterPassword/C/types.c
Normal file
63
MasterPassword/C/types.c
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
//
|
||||||
|
// MPTypes.h
|
||||||
|
// MasterPassword
|
||||||
|
//
|
||||||
|
// Created by Maarten Billemont on 02/01/12.
|
||||||
|
// Copyright (c) 2012 Lyndir. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
const char *CipherForType(MPElementType type, char seedByte) {
|
||||||
|
if (!(type & MPElementTypeClassGenerated)) {
|
||||||
|
fprintf(stderr, "Not a generated type: %d", type);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case MPElementTypeGeneratedMaximum:
|
||||||
|
char *ciphers = { "anoxxxxxxxxxxxxxxxxx", "axxxxxxxxxxxxxxxxxno" };
|
||||||
|
return ciphers[seedByte % 2];
|
||||||
|
case MPElementTypeGeneratedLong:
|
||||||
|
char *ciphers = { "CvcvnoCvcvCvcv", "CvcvCvcvnoCvcv", "CvcvCvcvCvcvno", "CvccnoCvcvCvcv", "CvccCvcvnoCvcv", "CvccCvcvCvcvno", "CvcvnoCvccCvcv", "CvcvCvccnoCvcv", "CvcvCvccCvcvno", "CvcvnoCvcvCvcc", "CvcvCvcvnoCvcc", "CvcvCvcvCvccno", "CvccnoCvccCvcv", "CvccCvccnoCvcv", "CvccCvccCvcvno", "CvcvnoCvccCvcc", "CvcvCvccnoCvcc", "CvcvCvccCvccno", "CvccnoCvcvCvcc", "CvccCvcvnoCvcc", "CvccCvcvCvccno" };
|
||||||
|
return ciphers[seedByte % 21];
|
||||||
|
case MPElementTypeGeneratedMedium:
|
||||||
|
char *ciphers = { "CvcnoCvc", "CvcCvcno" };
|
||||||
|
return ciphers[seedByte % 2];
|
||||||
|
case MPElementTypeGeneratedBasic:
|
||||||
|
char *ciphers = { "aaanaaan", "aannaaan", "aaannaaa" };
|
||||||
|
return ciphers[seedByte % 3];
|
||||||
|
case MPElementTypeGeneratedShort:
|
||||||
|
return "Cvcn";
|
||||||
|
case MPElementTypeGeneratedPIN:
|
||||||
|
return "nnnn";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char CharacterFromClass(char characterClass, char seedByte) {
|
||||||
|
switch (characterClass) {
|
||||||
|
case 'V':
|
||||||
|
return "AEIOU"[seedByte];
|
||||||
|
case 'C':
|
||||||
|
return "BCDFGHJKLMNPQRSTVWXYZ"[seedByte];
|
||||||
|
case 'v':
|
||||||
|
return "aeiou"[seedByte];
|
||||||
|
case 'c':
|
||||||
|
return "bcdfghjklmnpqrstvwxyz"[seedByte];
|
||||||
|
case 'A':
|
||||||
|
return "AEIOUBCDFGHJKLMNPQRSTVWXYZ"[seedByte];
|
||||||
|
case 'a':
|
||||||
|
return "AEIOUaeiouBCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz"[seedByte];
|
||||||
|
case 'n':
|
||||||
|
return "0123456789"[seedByte];
|
||||||
|
case 'o':
|
||||||
|
return "@&%?,=[]_:-+*$#!'^~;()/."[seedByte];
|
||||||
|
case 'x':
|
||||||
|
return "AEIOUaeiouBCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz0123456789!@#$%^&*()"[seedByte];
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "Unknown character class: %c", characterClass);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
42
MasterPassword/C/types.h
Normal file
42
MasterPassword/C/types.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
//
|
||||||
|
// MPTypes.h
|
||||||
|
// MasterPassword
|
||||||
|
//
|
||||||
|
// Created by Maarten Billemont on 02/01/12.
|
||||||
|
// Copyright (c) 2012 Lyndir. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSUInteger, MPElementContentType) {
|
||||||
|
MPElementContentTypePassword,
|
||||||
|
MPElementContentTypeNote,
|
||||||
|
MPElementContentTypePicture,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSUInteger, MPElementTypeClass) {
|
||||||
|
/** Generate the password. */
|
||||||
|
MPElementTypeClassGenerated = 1 << 4,
|
||||||
|
/** Store the password. */
|
||||||
|
MPElementTypeClassStored = 1 << 5,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSUInteger, MPElementFeature) {
|
||||||
|
/** Export the key-protected content data. */
|
||||||
|
MPElementFeatureExportContent = 1 << 10,
|
||||||
|
/** Never export content. */
|
||||||
|
MPElementFeatureDevicePrivate = 1 << 11,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSUInteger, MPElementType) {
|
||||||
|
MPElementTypeGeneratedMaximum = 0x0 | MPElementTypeClassGenerated | 0x0,
|
||||||
|
MPElementTypeGeneratedLong = 0x1 | MPElementTypeClassGenerated | 0x0,
|
||||||
|
MPElementTypeGeneratedMedium = 0x2 | MPElementTypeClassGenerated | 0x0,
|
||||||
|
MPElementTypeGeneratedBasic = 0x4 | MPElementTypeClassGenerated | 0x0,
|
||||||
|
MPElementTypeGeneratedShort = 0x3 | MPElementTypeClassGenerated | 0x0,
|
||||||
|
MPElementTypeGeneratedPIN = 0x5 | MPElementTypeClassGenerated | 0x0,
|
||||||
|
|
||||||
|
MPElementTypeStoredPersonal = 0x0 | MPElementTypeClassStored | MPElementFeatureExportContent,
|
||||||
|
MPElementTypeStoredDevicePrivate = 0x1 | MPElementTypeClassStored | MPElementFeatureDevicePrivate,
|
||||||
|
};
|
||||||
|
|
||||||
|
extern const char *CipherForType(MPElementType type, char seedByte);
|
||||||
|
extern const char CharacterFromClass(char characterClass, char seedByte);
|
Loading…
Reference in New Issue
Block a user