コード例 #1
0
ファイル: profile.py プロジェクト: hj91/cspace
def loadProfile(entry, password):
    ps = profileSettings()
    userName = ps.getData(entry + '/Name')
    keyId = ps.getData(entry + '/KeyID')
    encKey = ps.getData(entry + '/PrivateKey')
    rsaKey = RSAKey()
    try:
        rsaKey.fromPEM_PrivateKey(encKey, password)
    except RSAError:
        return None
    profile = Profile(rsaKey, userName, keyId, entry)
    contactsData = ps.getData(entry + '/ContactList', '')
    for line in contactsData.split('\n'):
        line = line.strip()
        if not line: continue
        name, hexKey = line.split(':')
        assert isValidUserName(name)
        pubKey = RSAKey()
        pubKey.fromDER_PublicKey(hexDecode(hexKey))
        contact = Contact(pubKey, name)
        profile.addContact(contact)
    return profile
コード例 #2
0
def getProfile():
    key = RSAKey()
    key.fromPEM_PrivateKey(file('ks.key').read())
    profile = UserProfile(key, 'ks')
    return profile
コード例 #3
0
ファイル: test_session.py プロジェクト: AchillesA/cspace
def getProfile() :
    key = RSAKey()
    key.fromPEM_PrivateKey( file('ks.key').read() )
    profile = UserProfile( key, 'ks' )
    return profile