MAJOR=4
MINOR=60
DEVNAME=tty60
    Ñˆâáé408ÚÀç ˜   Ñ‹      ¥’QoÓ0Çß÷)?ð¶\GÇsŒFR‰J][uA!\Û�­%qd+Ý§'©‹6¤MhâÉgûçÿÝÿ|üM¹*ªoë|®n°þòi1/€�#~�ˆeU¦‹Ëlr�8[2`–¨ÿ€¸ßï³ý4ó¡Æjƒ–Úæ#§(Ó¤™8ãã™8n�ÔÃ
œ5FÌ;m~�ßúŸ�6“wø ÛVj¤¶G%•5(c41öÁ«»1ºŸf<L9&‘AOº|ëõaLwñ¿ÒƒÂ±L¹=fÃ 8Y¸—�«»œ‘ï™à®­!•3tÊw·�ìî²ÚíÈ†rö}^¬~’_.Á³ËÙÇ"_^­òk&–²5åóÌMb2´^»�3úEø6Á·îáeÁ21¥‰*¸žœïQ,>µª|{9x}?8°á)•ý¯nHõW3Ö×›Ù²*ç›Ô=J<V÷ú�bb-ƒéJŒ"'3Iùm·�ýÕŸ-œJ®¶ÄÀ9<K¾¦xšŽÇÁã˜æü7ˆê·J      Óˆâáé560ÚÀç 0   Ó‹      Å•Qo›0…ßû+<?ìnBÒuJ�©‘-M¢4Ó4M{0Ø«€‘mÂ²_?…MaÍ´ª{ cs°¿sl]ÜWÁb¼þ²œ ëûZ~z?›Ž¶ >Æ Á:h^í^`2Ç'Z#€ªªìj`¹�õ
�¥CPZòHÛTSì_¹õ˜…Ü„jZäj®SæOsÊ¾##¥Vœ23sQ†)�Ž@E¦@±œÆ<e6e™°eGBf!*"e)•ÕfÙ�Ê¶<b
¶\ê’¤ õ®¾¨24Í²ºýÖ…Ã€Á�ÌÝÕÀýÿgöQ‘pÏX?JßÕ	Ú’”orkQ`ßåÙ)yx$raJòG{ÃcŒHª=üu:^|3:ÐIýµï”H{øÝØ›ß.¼ ûs’1ÈyÍ½ÑÜaF”F™ <æŒvŠñÿÑ=aÐh¦"ÉÍE~’‚±Ø¶‰TÄx½6ÙV5úT$ú%ŒåÝj2_ÓU	­§8Ñ½øVcI$Ë5
¸d‘rwÈ¢{�‡ª¸=vÑÁ©ä›Dc!�UþE<eþ˜‹*o'dÒ?›�±ƒ}skþFäôœ7Vß±zCäFÎBBSC>þ+z,RÊd›¼kWQ1i¢nÚËù¯;ùŸ#úËùÛÇåôü¤�¾5è¡þÍhØ½/|„J¶5gûMûþ|�.,$p(±.ì«¿Íïê'Ò’ÎÍ    6  Õˆl–ß=¿JJi?u8 ¸Û×1hß�þ]}‘¬ã€’Ê�ùë„d e¯êÁè ?÷    Õ#! /usr/bin/perl -w

# Copyright (C) 2001-2002 Oliver Ehli <elmy@acm.org>
# Copyright (C) 2001 Mike Schiraldi <raldi@research.netsol.com>
# Copyright (C) 2003 Bjoern Jacke <bjoern@j3e.de>
# Copyright (C) 2015 Kevin J. McCarthy <kevin@8t8.us>
#
#     This program is free software; you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation; either version 2 of the License, or
#     (at your option) any later version.
#
#     This program is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
#
#     You should have received a copy of the GNU General Public License
#     along with this program; if not, write to the Free Software
#     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

use strict;
use File::Copy;
use File::Glob ':glob';
use File::Temp qw(tempfile tempdir);

umask 077;

use Time::Local;

# helper routines
sub usage ();
sub mutt_Q ($);
sub mycopy ($$);
sub query_label ();
sub mkdir_recursive ($);
sub verify_files_exist (@);
sub create_tempfile (;$);
sub new_cert_structure ();
sub create_cert_chains (@);

# openssl helpers
sub openssl_exec (@);
sub openssl_format ($);
sub openssl_x509_query ($@);
sub openssl_hash ($);
sub openssl_fingerprint ($);
sub openssl_emails ($);
sub openssl_p12_to_pem ($$);
sub openssl_verify ($$);
sub openssl_crl_text($);
sub openssl_trust_flag ($$;$);
sub openssl_parse_pem ($$);
sub openssl_dump_cert ($);
sub openssl_purpose_flag ($$);

# key/certificate management methods
sub cm_list_certs ();
sub cm_add_entry ($$$$$$;$);
sub cm_add_cert ($);
sub cm_add_indexed_cert ($$$);
sub cm_add_key ($$$$$$);
sub cm_modify_entry ($$$;$);
sub cm_find_entry ($$);
sub cm_refresh_index ();

# op handlers
sub handle_init_paths ();
sub handle_change_label ($);
sub handle_add_cert ($);
sub handle_add_pem ($);
sub handle_add_p12 ($);
sub handle_add_chain ($$$);
sub handle_verify_cert($$);
sub handle_remove_pair ($);
sub handle_add_root_cert ($);


my $mutt = $ENV{MUTT_CMDLINE} || 'mutt';
my $opensslbin = "/usr/bin/openssl";
my $tmpdir;

# Get the directories mutt uses for certificate/key storage.

my $private_keys_path = mutt_Q 'smime_keys';
die "smime_keys is not set in mutt's configuration file"
   if length $private_keys_path == 0;

my $certificates_path = mutt_Q 'smime_certificates';
die "smime_certificates is not set in mutt's configuration file"
   if length $certificates_path == 0;

my $root_certs_path   = mutt_Q 'smime_ca_location';
die "smime_ca_location is not set in mutt's configuration file"
   if length $root_certs_path == 0;

my $root_certs_switch;
if ( -d $root_certs_path) {
  $root_certs_switch = -CApath;
} else {
  $root_certs_switch = -CAfile;
}


######
# OPS
######

if (@ARG