︙ | | | ︙ | |
317
318
319
320
321
322
323
324
325
326
327
328
329
330
|
#
# NOTE: Default to "EagleEnterprisePluginRootPublic.snk" in the current
# directory (which may not actually exist).
#
set publicKeyFile EagleEnterprisePluginRootPublic.snk
}
#
# NOTE: The spacing to use before the embedded certificate. This
# must match up with the number of blank lines used with the
# [linsert] command used to help produce the final embedded
# certificate string (below).
#
set embedSpacing [info newline]
|
>
>
>
>
>
>
|
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
|
#
# NOTE: Default to "EagleEnterprisePluginRootPublic.snk" in the current
# directory (which may not actually exist).
#
set publicKeyFile EagleEnterprisePluginRootPublic.snk
}
#
# NOTE: If the configuration file exists, load it now.
#
set configFileName [file join $path sign.settings.eagle]
if {[file exists $configFileName]} then {source $configFileName}
#
# NOTE: The spacing to use before the embedded certificate. This
# must match up with the number of blank lines used with the
# [linsert] command used to help produce the final embedded
# certificate string (below).
#
set embedSpacing [info newline]
|
︙ | | | ︙ | |
354
355
356
357
358
359
360
361
362
363
364
365
366
367
|
#
if {$embed && [isScriptFile $fileName]} then {
set shouldEmbed true
} else {
set shouldEmbed false
}
#
# NOTE: The existing embedded certificate, if any, must be
# removed prior to signing the (script?) file.
#
if {$shouldEmbed} then {
removeEmbeddedCertificate $fileName
}
|
>
>
>
>
>
|
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
|
#
if {$embed && [isScriptFile $fileName]} then {
set shouldEmbed true
} else {
set shouldEmbed false
}
#
# HOOK: After all arguments have been parsed and processed.
#
catch {certificate_hook phase0}
#
# NOTE: The existing embedded certificate, if any, must be
# removed prior to signing the (script?) file.
#
if {$shouldEmbed} then {
removeEmbeddedCertificate $fileName
}
|
︙ | | | ︙ | |
383
384
385
386
387
388
389
390
391
392
393
394
395
396
|
set certificateFile $fileName
#
# NOTE: Import the license certificate.
#
set certificate [certificate import $fileName]
#
# NOTE: Attempt to re-sign the license certificate file. Skip
# setting the Id as it should already be set correctly.
#
if {[certificate sign -encoding $encoding -settimestamp \
-setkey $certificate $privateKey] ne "SignedOk"} then {
error [appendArgs \
|
>
>
>
>
>
|
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
|
set certificateFile $fileName
#
# NOTE: Import the license certificate.
#
set certificate [certificate import $fileName]
#
# HOOK: Post-certificate object creation (import).
#
catch {certificate_hook phase1}
#
# NOTE: Attempt to re-sign the license certificate file. Skip
# setting the Id as it should already be set correctly.
#
if {[certificate sign -encoding $encoding -settimestamp \
-setkey $certificate $privateKey] ne "SignedOk"} then {
error [appendArgs \
|
︙ | | | ︙ | |
426
427
428
429
430
431
432
433
434
435
436
437
438
439
|
#
# NOTE: Create an empty certificate object.
#
set certificate [object create -alias \
Licensing.Components.Public.Certificate]
#
# NOTE: If the certificate vendor is available, set it.
#
if {[string length $vendor] > 0} then {
$certificate Vendor $vendor
}
|
>
>
>
>
>
|
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
|
#
# NOTE: Create an empty certificate object.
#
set certificate [object create -alias \
Licensing.Components.Public.Certificate]
#
# HOOK: Post-certificate object creation (create).
#
catch {certificate_hook phase1}
#
# NOTE: If the certificate vendor is available, set it.
#
if {[string length $vendor] > 0} then {
$certificate Vendor $vendor
}
|
︙ | | | ︙ | |
459
460
461
462
463
464
465
466
467
468
469
470
471
472
|
if {$shouldEmbed} then {
#
# NOTE: Set the entity value to the file contents that will, at
# some point, be seen by the script policy callback.
#
$certificate EntityValue [readEntityValue $fileName]
#
# NOTE: Attempt to sign the embedded file certificate and place
# the Id, timestamp, public key token, and signature bytes
# into the certificate we created above.
#
if {[certificate sign -encoding $encoding -setid -settimestamp \
-setkey -hashflags {+Basic Embedded} $certificate \
|
>
>
>
>
>
|
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
|
if {$shouldEmbed} then {
#
# NOTE: Set the entity value to the file contents that will, at
# some point, be seen by the script policy callback.
#
$certificate EntityValue [readEntityValue $fileName]
#
# HOOK: Post-certificate property setup (embedded).
#
catch {certificate_hook phase2}
#
# NOTE: Attempt to sign the embedded file certificate and place
# the Id, timestamp, public key token, and signature bytes
# into the certificate we created above.
#
if {[certificate sign -encoding $encoding -setid -settimestamp \
-setkey -hashflags {+Basic Embedded} $certificate \
|
︙ | | | ︙ | |
484
485
486
487
488
489
490
491
492
493
494
495
496
497
|
-hashflags {+Basic Embedded} $certificate \
$publicKey] ne "VerifiedOk"} then {
error [appendArgs \
"failed to verify embedded signature for " $fileType " \"" \
$fileName \"]
}
} else {
#
# NOTE: Attempt to sign the data file and place the Id, timestamp,
# public key token, and signature bytes into the blank
# certificate we created above.
#
if {[certificate signfile -encoding $encoding -setid -settimestamp \
-setkey $certificate $privateKey $fileName] ne "SignedOk"} then {
|
>
>
>
>
>
|
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
|
-hashflags {+Basic Embedded} $certificate \
$publicKey] ne "VerifiedOk"} then {
error [appendArgs \
"failed to verify embedded signature for " $fileType " \"" \
$fileName \"]
}
} else {
#
# HOOK: Post-certificate property setup (non-embedded).
#
catch {certificate_hook phase2}
#
# NOTE: Attempt to sign the data file and place the Id, timestamp,
# public key token, and signature bytes into the blank
# certificate we created above.
#
if {[certificate signfile -encoding $encoding -setid -settimestamp \
-setkey $certificate $privateKey $fileName] ne "SignedOk"} then {
|
︙ | | | ︙ | |
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
|
# NOTE: Show that we embedded it.
#
puts stdout [appendArgs \
"added embedded certificate to " $fileType " \"" $fileName \"]
}
#
# NOTE: Play nice and cleanup all the variables we created during
# the whole the signing process.
#
unset certificate privateKey publicKey embedSuffix embedPrefix; # dispose
unset privateKeyFile publicKeyFile certificateFile \
duration embed vendor fileName
if {[info exists path_set]} then {
unset -nocomplain path path_set
}
} else {
usage ""
}
|
>
>
>
>
>
|
|
<
|
|
|
>
|
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
|
# NOTE: Show that we embedded it.
#
puts stdout [appendArgs \
"added embedded certificate to " $fileType " \"" $fileName \"]
}
#
# HOOK: Script completion.
#
catch {certificate_hook phase3}
#
# NOTE: Play nice and cleanup all the variables we created during the
# whole the signing process.
#
unset -nocomplain fileName vendor embed duration entityType encoding \
privateKeyFile publicKeyFile configFileName embedSpacing embedPrefix \
embedSuffix publicKey privateKey shouldEmbed fileType certificate \
certificateFile data xmlNs xmlNsXsi xmlNsXsd spaces lines line
if {[info exists path_set]} then {
unset -nocomplain path path_set
}
} else {
usage ""
}
|