Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

98 Commits

Repository files navigation

PSCryptoPatterns

Advanced OOP and cryptographic programming patterns for PowerShell 7.x.

27 reference implementations covering the full production crypto stack: AES-GCM, RSA, hybrid encryption, key rotation, replay prevention, pinned memory, certificate chain validation, and the OOP patterns that hold it together at scale.

581 Pester tests. All green.

What is in here

https://cyguin.com/writing/powershell-cryptography

The PS crypto ecosystem is thin. Blog posts stop at AES-CBC. Nobody covers key rotation, algorithm agility, or pinned memory in a PowerShell context. This library covers the production concerns that actually matter.

FileTopic
01_ClassMechanics.ps1Static ctors, load order, hidden vs private, void return
02_Inheritance.ps1Constructor chaining, method override, type checking
03_InterfacePatterns.ps1IDisposable, IComparable, custom interface enforcement
04_AccessModifiers.ps1hidden, static, readonly simulation, closure-based private
05_FactoryMethod.ps1Factory method
06_AbstractFactory.ps1Abstract factory, crypto suite families
07_BuilderPattern.ps1Fluent construction with validation
08_ObjectPool.ps1RSA instance pooling
09_Prototype.ps1Deep clone
10_CompositionVsInheritance.ps1Composition, dependency injection
11_MixinScriptblock.ps1Scriptblock injection
12_GenericCollections.ps1Typed Dictionary, List, Queue in classes
13_TemplateMethod.ps1Algorithm skeleton, subclass fill
14_StateMachine.ps1Key lifecycle state machine
15_CommandPattern.ps1Operations as objects, undo
16_NullObject.ps1Null object pattern
17_EventsDelegates.ps1System.Action delegates as event hooks
18_UpdateTypeData.ps1Extending .NET types
19_MethodOverloading.ps1Overload resolution, coercion pitfalls
20_StaticConstructors.ps1Type-level initialization
21_OperatorOverloading.ps1IComparable, IEquatable
22_RecursiveTypes.ps1Self-referential classes
23_KeyRotation.ps1Rotating key manager with retention window
24_AlgorithmAgility.ps1Swap primitives via config
25_ReplayPrevention.ps1Nonce tracking with TTL window
26_SecureMemory.ps1Pinned GC buffers, zero-on-release, DPAPI
27_CertChainValidation.ps1X.509 chain validation, thumbprint pinning

Requirements

  • PowerShell 7.4+
  • Pester 5.x
Install-Module Pester -Force -SkipPublisherCheck

Run the tests

Invoke-Pester-Path './*.Tests.ps1'-Output Detailed

Load as a module

Import-Module ./PSCryptoPatterns.psd1

Read the paper

cyguin.com

License

MIT. See LICENSE.

About

Advanced OOP and cryptographic programming patterns for PS 7

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages