Home | History | Annotate | Download | only in Pkcs7Sign

Lines Matching refs:args

96   args = parser.parse_args()

126 args.InputFileName = args.InputFile.name
127 args.InputFileBuffer = args.InputFile.read()
128 args.InputFile.close()
133 OutputDir = os.path.dirname(args.OutputFile)
137 args.OutputFileName = args.OutputFile
140 if args.MonotonicCountStr.upper().startswith('0X'):
141 args.MonotonicCountValue = (long)(args.MonotonicCountStr, 16)
143 args.MonotonicCountValue = (long)(args.MonotonicCountStr)
145 args.MonotonicCountValue = (long)(0)
147 if args.Encode:
152 args.SignerPrivateCertFileName = args.SignerPrivateCertFile.name
153 args.SignerPrivateCertFile.close()
167 args.SignerPrivateCertFileName = os.path.join(os.path.dirname(os.path.realpath(Pkcs7ToolPath)), TEST_SIGNER_PRIVATE_CERT_FILENAME)
168 args.SignerPrivateCertFile = open(args.SignerPrivateCertFileName, 'rb')
169 args.SignerPrivateCertFile.close()
171 print 'ERROR: test signer private cert file %s missing' % (args.SignerPrivateCertFileName)
178 args.OtherPublicCertFileName = args.OtherPublicCertFile.name
179 args.OtherPublicCertFile.close()
193 args.OtherPublicCertFileName = os.path.join(os.path.dirname(os.path.realpath(Pkcs7ToolPath)), TEST_OTHER_PUBLIC_CERT_FILENAME)
194 args.OtherPublicCertFile = open(args.OtherPublicCertFileName, 'rb')
195 args.OtherPublicCertFile.close()
197 print 'ERROR: test other public cert file %s missing' % (args.OtherPublicCertFileName)
200 format = "%dsQ" % len(args.InputFileBuffer)
201 FullInputFileBuffer = struct.pack(format, args.InputFileBuffer, args.MonotonicCountValue)
206 Process = subprocess.Popen('%s smime -sign -binary -signer "%s" -outform DER -md sha256 -certfile "%s"' % (OpenSslCommand, args.SignerPrivateCertFileName, args.OtherPublicCertFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
214 args.OutputFile = open(args.OutputFileName, 'wb')
215 args.OutputFile.write(Signature)
216 args.OutputFile.write(args.InputFileBuffer)
217 args.OutputFile.close()
219 if args.Decode:
224 args.TrustedPublicCertFileName = args.TrustedPublicCertFile.name
225 args.TrustedPublicCertFile.close()
239 args.TrustedPublicCertFileName = os.path.join(os.path.dirname(os.path.realpath(Pkcs7ToolPath)), TEST_TRUSTED_PUBLIC_CERT_FILENAME)
240 args.TrustedPublicCertFile = open(args.TrustedPublicCertFileName, 'rb')
241 args.TrustedPublicCertFile.close()
243 print 'ERROR: test trusted public cert file %s missing' % (args.TrustedPublicCertFileName)
246 if not args.SignatureSizeStr:
250 if args.SignatureSizeStr.upper().startswith('0X'):
251 SignatureSize = (long)(args.SignatureSizeStr, 16)
253 SignatureSize = (long)(args.SignatureSizeStr)
257 elif SignatureSize > len(args.InputFileBuffer):
261 args.SignatureBuffer = args.InputFileBuffer[0:SignatureSize]
262 args.InputFileBuffer = args.InputFileBuffer[SignatureSize:]
264 format = "%dsQ" % len(args.InputFileBuffer)
265 FullInputFileBuffer = struct.pack(format, args.InputFileBuffer, args.MonotonicCountValue)
270 open(args.OutputFileName, 'wb').write(FullInputFileBuffer)
275 Process = subprocess.Popen('%s smime -verify -inform DER -content %s -CAfile %s' % (OpenSslCommand, args.OutputFileName, args.TrustedPublicCertFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
276 Process.communicate(input=args.SignatureBuffer)[0]
279 os.remove (args.OutputFileName)
282 open(args.OutputFileName, 'wb').write(args.InputFileBuffer)