- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
#include <stdio.h>
#include "gost.h"
int main() {
    MemoryFile mf("root.cer");
    MemoryFile mf2("test.cer");
    ASN1Parser parser(mf);
    ASN1Parser parser2(mf2);
    ASN1Block e1[2];
    parser.Split("30{30{A0#,02$1,30#,30#,30#,30#,30{30#,03$2},A3#},30#,03#}", e1);
    unsigned char px[32], py[32], r[32], s[32], h[32];
    for (int i=0;i<32;i++) {
        px[i] = mf.data[e1[1].offset+i+3];
        py[i] = mf.data[e1[1].offset+i+35];
    }
    parser2.Split("30{30$1,30#,03$2}", e1);
    for (int i=0;i<32;i++) {
        r[i] = mf2.data[e1[1].offset+64-i];
        s[i] = mf2.data[e1[1].offset+32-i];
    }
    Gost3411 hash;
    hash.AddData(mf2.data+e1[0].offset-4, e1[0].size+4);
    hash.Finish(h);
    Gost3410 g;
    if (!g.VerifySignature(h, px, py, r, s)) {
        printf("Invalid!");
    } else {
        printf("Valid!");
    }
    return 0;
}