コード例 #1
0
ファイル: test_gpg.py プロジェクト: michizhou/in-toto
    def setUpClass(self):
        # Load test raw public key bundle from rsa keyring, used to construct
        # erroneous gpg data in tests below.
        keyid = "F557D0FF451DEF45372591429EA70BD13D883381"

        gpg_keyring_path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), "gpg_keyrings", "rsa")
        homearg = "--homedir {}".format(gpg_keyring_path).replace("\\", "/")

        cmd = GPG_EXPORT_PUBKEY_COMMAND.format(keyid=keyid, homearg=homearg)
        proc = process.run(cmd, stdout=process.PIPE, stderr=process.PIPE)

        self.raw_key_data = proc.stdout
        self.raw_key_bundle = parse_pubkey_bundle(self.raw_key_data)
コード例 #2
0
import in_toto.process as process

# Inherits from in_toto base logger (c.f. in_toto.log)
log = logging.getLogger(__name__)

# By default, we assume and test that gpg2 exists. Otherwise, we assume gpg
# exists.
GPG_COMMAND = "gpg2"
GPG_VERSION_COMMAND = GPG_COMMAND + " --version"

FULLY_SUPPORTED_MIN_VERSION = "2.1.0"

try:
    proc = process.run(GPG_VERSION_COMMAND,
                       stdout=process.PIPE,
                       stderr=process.PIPE)

except OSError:  # pragma: no cover
    GPG_COMMAND = "gpg"
    GPG_VERSION_COMMAND = GPG_COMMAND + " --version"

GPG_SIGN_COMMAND = GPG_COMMAND + \
                   " --detach-sign --digest-algo SHA256 {keyarg} {homearg}"
GPG_EXPORT_PUBKEY_COMMAND = GPG_COMMAND + " {homearg} --export {keyid}"

# The packet header is described in RFC4880 section 4.2, and the respective
# packet types can be found in sections 5.2 (signature packet), 5.5.1.1
# (master pubkey packet) and 5.5.1.2 (sub pubkey packet).
PACKET_TYPES = {
    'signature_packet': 0x02,
コード例 #3
0
ファイル: constants.py プロジェクト: leewalter/in-toto
"""

import in_toto.gpg.rsa as rsa
import in_toto.gpg.dsa as dsa

import in_toto.process as process

# By default, we assume and test that gpg2 exists. Otherwise, we assume gpg
# exists.
GPG_COMMAND = "gpg2"
GPG_VERSION_COMMAND = GPG_COMMAND + " --version"

FULLY_SUPPORTED_MIN_VERSION = "2.1.0"

try:
  process.run(GPG_VERSION_COMMAND, stdout=process.DEVNULL,
    stderr=process.DEVNULL)
except OSError: # pragma: no cover
  GPG_COMMAND = "gpg"
  GPG_VERSION_COMMAND = GPG_COMMAND + " --version"

GPG_SIGN_COMMAND = GPG_COMMAND + \
                   " --detach-sign --digest-algo SHA256 {keyarg} {homearg}"
GPG_EXPORT_PUBKEY_COMMAND = GPG_COMMAND + " {homearg} --export {keyid}"

# The packet header is described in RFC4880 section 4.2, and the respective
# packet types can be found in sections 5.2 (signature packet), 5.5.1.1
# (master pubkey packet) and 5.5.1.2 (sub pubkey packet).
PACKET_TYPES = {
    'signature_packet': 0x02,
    'master_pubkey_packet': 0x06,
    'pub_subkey_packet': 0x0E,