Exemplo n.º 1
0
 def setUp(self):
     self.agent = DiskAgent("127.0.0.1", [])
     #### Sign the agent
     binstr = cPickle.dumps(self.agent.compLocal, 1)
     _privkey = getPrivateKey(self.agent.masterip)
     _pubkey = getPublicKey(self.agent.masterip)
     self.agent.serverSignature = _privkey.sign(binstr, b"")[0]
Exemplo n.º 2
0
class TestAgentSecurity(unittest.TestCase):
    def setUp(self):
        self.agent = DiskAgent("127.0.0.1", [])
        #### Sign the agent
        binstr = cPickle.dumps(self.agent.compLocal, 1)
        _privkey = getPrivateKey(self.agent.masterip)
        _pubkey = getPublicKey(self.agent.masterip)
        self.agent.serverSignature = _privkey.sign(binstr, b"")[0]

    def test_execution(self):
        self.assertGreater(self.agent.compute(), 0)

    def test_security_on_code_change(self):
        newagent = MaliciousAgent("127.0.0.51", [])
        self.agent.compLocal = newagent.compLocal
        self.assertEqual(self.agent.compute(), -1)
Exemplo n.º 3
0
class TestAgentFunctionality(unittest.TestCase):
    def setUp(self):
        self.agent = DiskAgent("127.0.0.1", [])
        #### Sign the agent
        binstr = cPickle.dumps(self.agent.compLocal, 1)
        _privkey = getPrivateKey(self.agent.masterip)
        _pubkey = getPublicKey(self.agent.masterip)
        self.agent.serverSignature = _privkey.sign(binstr, b"")[0]

    def test_compLocal(self):
        self.assertGreater(self.agent.compute(), 0)
Exemplo n.º 4
0
from DiskAgent import * 
import cPickle
import rsa

#### create new agent
#agentx = DiskAgent(masterip,groute)
agentx = DiskAgent(0, [])
#### Sign the agent
binstr = cPickle.dumps(agentx.compLocal, 1)
(pub, priv) = rsa.newkeys(512)
agentx.serverSignature = rsa.sign(binstr, priv, 'MD5')
agentx.serverPubKey = pub
agentx.compute()
Exemplo n.º 5
0
        masterip = cp.get("master", "masterip")
        print "Masterip:", masterip
        hops = cp.getint("itinerary", "hops")
        while hops > 0:
            attrname = "node" + str(i)
            groute.append(cp.get("itinerary", attrname))
            hops = hops - 1
            i = i + 1
    else:
        print "Can not find required configuration file\n"
        sys.exit(1)


#### main program starts
mafinit("maf.conf")

#### create new agent
agentx = DiskAgent(masterip, groute)
#### Sign the agent

binstr = cPickle.dumps(agentx.compLocal, 1)
_privkey = getPrivateKey(masterip)
_pubkey = getPublicKey(masterip)
agentx.serverSignature = _privkey.sign(binstr, b"")[0]

#### display some information related to this agent
agentx.dispInfo()

#### migrate this agent
migrate(agentx)