aboutsummaryrefslogtreecommitdiff
path: root/lib/pluginloader/meson.build
blob: 5e7c39c2f709ecaadca9a818abdcbaf3d662aa34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
python = import('python')
python3 = python.find_installation('python3')

openssl = find_program('openssl', required: true)

private_pem = custom_target('privateKey.pem',
  output: 'privateKey.pem',
  command: [ openssl, 'genrsa', '-out', '@OUTPUT@', '4096' ]
)

public_pem = custom_target('publicKey.pem',
  input: private_pem,
  output: 'publicKey.pem',
  command: [ openssl, 'rsa', '-in', '@INPUT@', '-pubout', '-out', '@OUTPUT@' ]
)

publicKey_h = custom_target('publicKey_h',
  input: files('ssl-keygen.py'),
  output: 'publicKey.h',
  command: [python3, '@INPUT@',
    '--private', private_pem, '--public', public_pem,
    '--output=@OUTPUT@', '--array-name=publicKey_pem']
)

dep_pluginloader = declare_dependency(
    include_directories: include_directories('.'),
    link_with: static_library('plugin', 
        ['pluginloader.cpp', publicKey_h],
        include_directories: include_directories('.'),
        dependencies: [dep_qt5, dependency('openssl', required: true)])
)

# generate a test file that would be signed
unsignedfile_dat = custom_target('unsignedfile.dat', input: 'write-random.py', output: 'unsignedfile.dat', command: [ python3, '@INPUT@', '--output=@OUTPUT@' ])

signedfile_dat = custom_target('signedfile.dat', input: 'write-random.py', output: 'signedfile.dat', command: [ python3, '@INPUT@', '--output=@OUTPUT@' ])

badsignedfile_dat = custom_target('badsignedfile.dat', input: 'write-random.py', output: 'badsignedfile.dat', command: [ python3, '@INPUT@', '--output=@OUTPUT@' ])
badsignedfile_sig = custom_target('badsignedfile.dat.sig', input: 'write-random.py', output: 'badsignedfile.dat.sig', command: [ python3, '@INPUT@', '--output=@OUTPUT@' ])

# sign test file
signedfile_sig = custom_target('signedfile.dat.sig',
  input: signedfile_dat,
  output: 'signedfile.dat.sig',
  command: [ openssl, 'dgst', '-sha256', '-sign', private_pem, '-out', '@OUTPUT@', '@INPUT@' ]
)

signedfile_idep = declare_dependency(sources: [ unsignedfile_dat, signedfile_dat, signedfile_sig, badsignedfile_dat, badsignedfile_sig ])

pluginloader_sigmatch = executable('pluginloader-sigmatch',
  sources: [ 'test/pluginloader-sigmatch.cpp' ],
  dependencies: [ dep_qt5, dep_catch, dep_pluginloader, signedfile_idep ]
)

test('signature matching', pluginloader_sigmatch, suite: 'pluginloader',
  env: {
    'SIGNEDFILE' : signedfile_dat.full_path(),
    'UNSIGNEDFILE': unsignedfile_dat.full_path(),
    'BADSIGNEDFILE': badsignedfile_dat.full_path()
  },
)

poi_plugin_loader = executable('poi-plugin-load', dependencies: [ dep_qt5, dep_spdlog, dep_pluginloader ], sources: 'test/pluginloader-load.cpp')

# make sure this fails when no plugin or an invalid file is passed
test('load', poi_plugin_loader, suite: 'pluginloader', should_fail: true)
test('load', poi_plugin_loader, suite: 'pluginloader', args: files('meson.build'), should_fail: true)