4
%% Copyright Ericsson AB 2008-2009. All Rights Reserved.
6
%% The contents of this file are subject to the Erlang Public License,
7
%% Version 1.1, (the "License"); you may not use this file except in
8
%% compliance with the License. You should have received a copy of the
9
%% Erlang Public License along with this software. If not, it can be
10
%% retrieved online at http://www.erlang.org/.
12
%% Software distributed under the License is distributed on an "AS IS"
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
%% the License for the specific language governing rights and limitations
20
-module(test_modified_x420).
22
%-compile(export_all).
23
-export([compile/1, test_io/1]).
25
-include("test_server.hrl").
28
?line DataDir = ?config(data_dir,Config),
29
?line OutDir = ?config(priv_dir,Config),
31
ok = asn1ct:compile(filename:join([DataDir,modified_x420,"PKCS7"]),[der,{outdir,OutDir}]),
32
ok = asn1ct:compile(filename:join([DataDir,modified_x420,"InformationFramework"]),[der,{outdir,OutDir}]),
33
ok = asn1ct:compile(filename:join([DataDir,modified_x420,"AuthenticationFramework"]),[der,{outdir,OutDir}]).
36
io:format("~p~n~n", [catch test(Config)]).
39
?line DataDir = ?config(data_dir,Config),
40
% ?line OutDir = ?config(priv_dir,Config),
42
?line Der = read_pem(filename:join([DataDir,modified_x420,"p7_signed_data.pem"])),
43
?line {ok, {_,_,SignedData}} = 'PKCS7':decode('ContentInfo', Der),
44
?line {ok,_} = 'PKCS7':decode('SignedData', SignedData).
47
?line {ok, Bin} = file:read_file(File),
48
?line ssl_base64:join_decode(lists:flatten(extract_base64(Bin))).
52
extract_base64(Binary) ->
53
extract_base64_lines(string:tokens(binary_to_list(Binary), "\n")).
55
extract_base64_lines(["-----BEGIN"++_ | Lines]) ->
56
take_base64_lines(Lines, _Acc = []);
57
extract_base64_lines([_|Lines]) ->
58
extract_base64_lines(Lines);
59
extract_base64_lines([]) ->
62
take_base64_lines(["-----END"++_|_], Acc) ->
64
take_base64_lines([L|Lines], Acc) ->
65
take_base64_lines(Lines, [L|Acc]);
66
take_base64_lines([], Acc) ->