Пример #1
0
from playground.network.common.statemachine import StateMachine
from playground.network.common.statemachine import StateMachineError

from playground.playgroundlog import packetTrace, logging
from playground.error import GetErrorReporter
from pprint import pprint
from playground.network.common.Packet import Packet, PacketStorage, IterateMessages

from CertFactory import getCertsForAddr, getPrivateKeyForAddr, getRootCert
from Crypto.Hash import SHA256
from Crypto.PublicKey import RSA
from Crypto.Signature import PKCS1_v1_5
from random import randint
from playground.crypto import X509Certificate

logger = logging.getLogger(__name__)
errReporter = GetErrorReporter(__name__)

"""
        Step 1: Define Rip Message Body (handshake version)
"""

class RipMessage(MessageDefinition):
    PLAYGROUND_IDENTIFIER = "RipTestProtocol.RipTestStack.RipMessage"
    MESSAGE_VERSION = "1.0"
    BODY = [
        ("ACK", BOOL1, DEFAULT_VALUE(False)),
        ("SNN", BOOL1, DEFAULT_VALUE(False)),
        ("Signature", STRING, DEFAULT_VALUE("")),
        ("Certificate", LIST(STRING), OPTIONAL),
        ("Data", STRING, DEFAULT_VALUE(""))
Пример #2
0
from ServiceMessages import PurchaseDecryptionKey, RunMobileCodeFailure, AcquireDecryptionKeyFailure
from ServiceMessages import RerequestDecryptionKey, GeneralFailure, ResultDecryptionKey, SessionRunMobileCode
from ServiceMessages import RunMobileCodeAck, CheckMobileCodeResult

import random, time, math, os, shelve, pickle, sys, binascii

from Crypto.Cipher import AES
from Crypto.Hash import SHA
from Crypto.PublicKey import RSA
from Crypto.Signature import PKCS1_v1_5

from playground.network.client.ClientMessageHandlers import RunMobileCodeHandler, MobileCodeCallbackHandler

from playground.playgroundlog import packetTrace, logging, LoggingContext
from binhex import binhex
logger = logging.getLogger(__file__)

from apps.bank.BankCore import LedgerLine

RANDOM_u64 = lambda: random.randint(0, (2**64) - 1)

LOCATION_OF_PLAYGROUND = os.path.dirname(playground.__file__)

MOBILE_CODE_SERVICE_FIXED_PLAYGROUND_PORT = 800


class CodeExecutionContext(object):
    def __init__(self):
        self.startTime = None
        self.cookie = None
        self.runMobileCodeHash = None