def location_test(self,
                      cfg_file,
                      table_prefix="table_test1",
                      default_vis="default",
                      num_entries=10000,
                      num_rows=1000):

        table_prefix = sanitize(table_prefix) + '_' + sanitize(loc)

        generate_data(self.filename,
                      self.seed,
                      default_vis=default_vis,
                      num_entries=num_entries,
                      num_rows=num_rows)

        for signer_id, sigclass in self.signer_ids:

            _, privkey = sigclass.test_keys()

            table = table_prefix + '_' + sanitize(signer_id)

            conf = new_config(cfg_file, self.conn)

            signer = AccumuloSigner(privkey, sig_f=sigclass, conf=conf)
            write_and_sign_data(self.filename, self.conn, table, signer)
            verif_key, _ = self.pki.get_verifying_key(signer_id)
            verify_data(self.conn, table, verif_key, False, conf=conf)
    def table_test(self,
                   table_prefix="table_test1",
                   default_vis="default",
                   num_entries=10000,
                   num_rows=1000):

        table_prefix = sanitize(table_prefix)

        generate_data(self.filename,
                      self.seed,
                      default_vis=default_vis,
                      num_entries=num_entries,
                      num_rows=num_rows)

        for signer_id, sigclass in self.signer_ids:

            _, privkey = sigclass.test_keys()

            table = table_prefix + '_' + sanitize(signer_id)

            signer = AccumuloSigner(privkey, sig_f=sigclass)
            write_and_sign_data(self.filename,
                                self.conn,
                                table,
                                signer,
                                include_table=True)
            verif_key, _ = self.pki.get_verifying_key(signer_id)
            verify_data(self.conn, table, verif_key, False, include_table=True)
    def full_benchmark(self,
                       table_prefix="full_benchmarking",
                       default_vis="default",
                       signClass=None,
                       num_entries=10000,
                       num_rows=1000):
        """ Either run a single benchmark (sign & verify) on one signature
            class, or run it with no signing class (just write & read) to get
            a baseline time.
        """

        table_prefix = sanitize(table_prefix)

        conn = self.conn

        if signClass:
            table = table_prefix + '_' + sanitize(signClass.name)
        else:
            table = table_prefix + '_baseline'

        if signClass:
            pubkey, privkey = signClass.test_keys()
            signer = AccumuloSigner(privkey, sig_f=signClass)
            start_time = time.clock()
            write_and_sign_data(self.filename,
                                conn,
                                table,
                                signer,
                                benchmark=False)
            end_time = time.clock()
            total_sign_time = end_time - start_time

            start_time = time.clock()
            verify_data(conn, table, pubkey, benchmark=False)
            end_time = time.clock()
            total_verif_time = end_time - start_time
        else:
            start_time = time.clock()
            write_data(self.filename, conn, table)
            end_time = time.clock()
            total_sign_time = end_time - start_time

            count = 0
            start_time = time.clock()
            for entry in conn.scan(table):
                count += 1
            end_time = time.clock()
            total_verif_time = end_time - start_time

        return (total_sign_time, total_verif_time)
    def run_test(self,
                 table="test_table_5",
                 default_vis="default",
                 num_entries=100,
                 num_rows=15,
                 signClassName='RSASSA_PKCS1-v1_5',
                 write=True,
                 benchmark=False):
        """ Runs one iteration of the signature test. If benchmark is set to
            True, returns the lengths of time it took to sign all the entries
            and the time it took to verify all the entries.
        """

        table = sanitize(table)
        seed = self.seed

        if signClassName == 'ALL':
            for signClass in ALL_SIGNATURES:
                self.run_test(table + '_' + sanitize(signClass.name),
                              default_vis, num_entries, num_rows,
                              signClass.name, write, benchmark)
            return

        signClass = SIGNATURE_FUNCTIONS[signClassName]

        pubkey, privkey = signClass.test_keys()

        if write:
            signer = AccumuloSigner(privkey, sig_f=signClass)

            if not seed:
                # set a new seed if one wasn't specified
                seed = str(time.time())

            generate_data(self.filename,
                          seed,
                          default_vis=default_vis,
                          num_entries=num_entries,
                          num_rows=num_rows)

            sout = write_and_sign_data(self.filename, self.conn, table, signer,
                                       benchmark)

        vout = verify_data(self.conn, table, pubkey, benchmark)

        if benchmark:
            sign_start, sign_end = sout
            verif_success, verif_start, verif_end = vout

            print "Time taken to sign: %s" % str(sign_end - sign_start)
            print "Time taken to verify: %s" % str(verif_end - verif_start)

            return sign_end - sign_start, verif_end - verif_start
    def id_test(self,
                table_prefix="id_test",
                default_vis="default",
                num_entries=10000,
                num_rows=1000):

        table_prefix = sanitize(table_prefix)

        generate_data(self.filename,
                      self.seed,
                      default_vis=default_vis,
                      num_entries=num_entries,
                      num_rows=num_rows)

        for signer_id, sigclass in self.signer_ids:

            _, privkey = sigclass.test_keys()
            table = table_prefix + '_' + sanitize(signer_id)

            signer = AccumuloSigner(privkey,
                                    sig_f=sigclass,
                                    signerID=signer_id)
            write_and_sign_data(self.filename, self.conn, table, signer)
            verify_data(self.conn, table, self.pki, sigclass)