Native or External?




                 Lessons learned implementing
                 cryptography for VisualWorks




Martin Kobetic
Cincom Smalltalk Engineering
ESUG 2011
Let's implement SSL!
DES, MD5, SHA, RSA, DSA, RC4, X.509, ASN.1, DER, ...

* SSL 3.0, RSA, DES, RC4, basic X.509 (RSA only)
* DH, DSA, + SSL integration, AES
* X.509 on ASN.1, faster RSA (CRT),...
* new ASN.1 (read/write), more X.509
* protocols/S (HTTPS, SMTPS,....)
What is Cryptography
hashes
MD5, SHA1, SHA256, ...

secret key (symmetric) ciphers
AES, DES, RC4,...

public key algorithms
* signing (RSA, DSA, ECDSA)
* encryption (RSA)
* key agreement (DH, ECDH)
Hashes - Native
(MD5 hash: 'Hello') asHexString.

buffer := ByteArray new: 16384.
hash := SHA new.
file := (ObjectMemory imageFilename
            withEncoding: #binary) readStream.
[     [ file atEnd ] whileFalse: [ | read |
            read :=
                file nextAvailable: buffer size
                      into: buffer
                      startingAt: 1.
            hash updateWith: buffer from: 1 to: read ].
] ensure: [ file close ].
hash digest asHexString.
Hashes - External
buffer := ByteArray new: 16384.
hash := Hash new algorithm: 'SHA1'; yourself.
file := (ObjectMemory imageFilename
            withEncoding: #binary) readStream.
[     [ file atEnd ] whileFalse: [ | read |
            read :=
                file nextAvailable: buffer size
                      into: buffer
                      startingAt: 1.
            hash update: read from: buffer ].
      hash finish asHexString
] ensure: [ file close. hash release ].
Hashes - Xtreams
((ObjectMemory imageFilename reading
    hashing: 'SHA1'
)   -= 0;
    close;
    digest
) asHexString
Ciphers - Native
message := 'Hello World!' asByteArrayEncoding: #ascii.
key := 'Open Sesame!!!!!' asByteArrayEncoding: #ascii.

((ARC4 key: key) encrypt: message) asHexString.

cipher := AES key: key.

cipher := CipherBlockChaining on: cipher.
iv := ByteArray new: 16 withAll: 1.
cipher setIV: iv.

cipher := BlockPadding on: cipher.
(cipher encrypt: message) asHexString
Ciphers - Speed
megs := 100.
buffer := ByteArray new: 1000.
time := [
    megs * 1000 timesRepeat: [
          1 to: buffer size do: [ :i |
               buffer at: i put: (buffer at: i) ]]
    ] timeToRun.
megs asFloat / time asSeconds.

time := [ self readWriteMegs: megs ] timeToRun.
megs asFloat / time asSeconds
Ciphers - External
buffer := ByteArray new: message size + iv size.
cipher := Cipher new.
padding := iv size - (message size  iv size).
padding := ByteArray new: padding withAll: padding.
[   | count |
    cipher algorithm: 'AES' mode: 'CBC'
         key: key iv: iv encrypt: true.
    count := cipher update: message size
                  from: message into: buffer.
    result := buffer copyFrom: 1 to: count.
    count := cipher update: padding size
                  from: padding into: buffer.
    result := result, (buffer copyFrom: 1 to: count).
    count := cipher finishInto: buffer.
    result, (buffer copyFrom: 1 to: count)
] ensure: [ cipher release ]
Ciphers - Xtreams
((( ByteArray new writing
         encrypting: 'AES' mode: 'CBC' key: key iv: iv
)   hashing: 'SHA1'
)   write: message;
    write: padding;
    close;
    terminal
) asHexString
Public Key - Native
keys := RSAKeyGenerator keySize: 1024.
keys publicKey.

rsa := RSA new privateKey: keys privateKey.
rsa useMD5.
sig := rsa sign: message.
Public Key - External
key := PrivateKey RSALength: 1024.
[   | digest |
    digest := (message reading hashing: 'SHA1')
                  -= 0; close; digest.
    key sign: digest
         hash: 'SHA1'
         padding: 'PKCS1'
] ensure: [ key release ]
Native - Pros
* understanding and know-how
* ease of use and deployment
* automatically cross platform
* easy integration
* debugging
Native - Cons
* maintenance/evolution
* security issues
* speed
* certification
* hardware integration
* export restrictions
External - Pros
* development cost (maybe)
* evolves for free (hopefully)
* speed
* certification (possibly)
* hardware integration (possibly)
External - Cons
* platform coverage
* integration issues
* support
* FFI issues
* brittleness
Summary
* seamless use
* seamless deployment
* platform coverage
* capability coverage
* extensibility
* other constraints
     * certification/approved implementations
     * hardware support
     * performance

More Related Content

PDF
VisualWorks Security Reloaded - STIC 2012
PDF
OSMC 2012 | Distributed Monitoring mit NSClient++ by Michael Medin
PDF
Ruby on embedded devices rug::b Aug 2014
PPTX
Caching solutions with Redis
PDF
A promising approach for debugging remote promises
PDF
Introduction to Redis
PPTX
Redis Introduction
PDF
Nodejs - Should Ruby Developers Care?
VisualWorks Security Reloaded - STIC 2012
OSMC 2012 | Distributed Monitoring mit NSClient++ by Michael Medin
Ruby on embedded devices rug::b Aug 2014
Caching solutions with Redis
A promising approach for debugging remote promises
Introduction to Redis
Redis Introduction
Nodejs - Should Ruby Developers Care?

What's hot (20)

PDF
Introduction to redis - version 2
PPTX
Linux 101
PDF
Container Security via Monitoring and Orchestration - Container Security Summit
PDF
Vault encryption support
PDF
Rust: Systems Programming for Everyone
PDF
Nodejs - A quick tour (v4)
PPT
Ceph Day Berlin: Ceph and iSCSI in a high availability setup
PDF
Accumulo Summit 2015: Accumulo In-Depth: Building Bulk Ingest [Sponsored]
PDF
Paris Redis Meetup Introduction
PDF
Cryptography for Smalltalkers 2
PDF
Node.js in production
PDF
Nodejs - A quick tour (v5)
PDF
What is new in CFEngine 3.6
PDF
Nodejs - A-quick-tour-v3
PDF
Kicking ass with redis
KEY
Node.js - A practical introduction (v2)
PDF
Vault
PDF
Nodejs a-practical-introduction-oredev
KEY
Node.js - As a networking tool
PDF
Relayd: a load balancer for OpenBSD
Introduction to redis - version 2
Linux 101
Container Security via Monitoring and Orchestration - Container Security Summit
Vault encryption support
Rust: Systems Programming for Everyone
Nodejs - A quick tour (v4)
Ceph Day Berlin: Ceph and iSCSI in a high availability setup
Accumulo Summit 2015: Accumulo In-Depth: Building Bulk Ingest [Sponsored]
Paris Redis Meetup Introduction
Cryptography for Smalltalkers 2
Node.js in production
Nodejs - A quick tour (v5)
What is new in CFEngine 3.6
Nodejs - A-quick-tour-v3
Kicking ass with redis
Node.js - A practical introduction (v2)
Vault
Nodejs a-practical-introduction-oredev
Node.js - As a networking tool
Relayd: a load balancer for OpenBSD
Ad

Viewers also liked (9)

PDF
Talents: Dynamically Composable Units of Reuse
PDF
Magritte Magic
PDF
IronSmalltalk
PDF
Show Us: SS7 Update
PDF
DeltaImpact: Assessing semantic merge conflicts with Dependency Analysis
PDF
Code Transformation by Direct Transformation of ASTs
PDF
Bloc: a Modern Core for Highly Dynamic Graphics
PDF
Sistemas de Telecomunicações - Aula 07 - Sistema Telefônico Fixo e Sistema Te...
PDF
Sistemas de Telecomunicações - Aula 06 - Estrutura da rede pública de Telecom...
Talents: Dynamically Composable Units of Reuse
Magritte Magic
IronSmalltalk
Show Us: SS7 Update
DeltaImpact: Assessing semantic merge conflicts with Dependency Analysis
Code Transformation by Direct Transformation of ASTs
Bloc: a Modern Core for Highly Dynamic Graphics
Sistemas de Telecomunicações - Aula 07 - Sistema Telefônico Fixo e Sistema Te...
Sistemas de Telecomunicações - Aula 06 - Estrutura da rede pública de Telecom...
Ad

Similar to Native or External? (20)

PPT
12 symmetric key cryptography
PPTX
Cryptography for Absolute Beginners (May 2019)
PDF
How does cryptography work? by Jeroen Ooms
PPTX
Django cryptography
PDF
Web cryptography javascript
PPTX
Message Authentication using Message Digests and the MD5 Algorithm
PPTX
Rust Hack
PPTX
Secure erasure code based cloud storage system with secure data forwarding
PDF
$kernel->infect(): Creating a cryptovirus for Symfony2 apps
PDF
Encryption Recap: A Refresher on Key Concepts
PDF
Next Generation DevOps in Drupal: DrupalCamp London 2014
PPTX
Secureerasurecodebasedcloudstoragesystemwithsecuredataforwarding
PDF
OpenSSL programming (still somewhat initial version)
PPSX
comp security lab.ppsx
PDF
introduction to jsrsasign
PPT
Cryptography for Smalltalkers 2 - ESUG 2006
PPTX
Introduction to InSpec and 1.0 release update
PDF
Shellcode Disassembling - Reverse Engineering
PDF
Pulsar Summit Asia - Running a secure pulsar cluster
PDF
Computer network (4)
12 symmetric key cryptography
Cryptography for Absolute Beginners (May 2019)
How does cryptography work? by Jeroen Ooms
Django cryptography
Web cryptography javascript
Message Authentication using Message Digests and the MD5 Algorithm
Rust Hack
Secure erasure code based cloud storage system with secure data forwarding
$kernel->infect(): Creating a cryptovirus for Symfony2 apps
Encryption Recap: A Refresher on Key Concepts
Next Generation DevOps in Drupal: DrupalCamp London 2014
Secureerasurecodebasedcloudstoragesystemwithsecuredataforwarding
OpenSSL programming (still somewhat initial version)
comp security lab.ppsx
introduction to jsrsasign
Cryptography for Smalltalkers 2 - ESUG 2006
Introduction to InSpec and 1.0 release update
Shellcode Disassembling - Reverse Engineering
Pulsar Summit Asia - Running a secure pulsar cluster
Computer network (4)

More from ESUG (20)

PDF
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
PDF
Micromaid: A simple Mermaid-like chart generator for Pharo
PDF
Directing Generative AI for Pharo Documentation
PDF
Even Lighter Than Lightweiht: Augmenting Type Inference with Primitive Heuris...
PDF
Composing and Performing Electronic Music on-the-Fly with Pharo and Coypu
PDF
Gamifying Agent-Based Models in Cormas: Towards the Playable Architecture for...
PDF
Analysing Python Machine Learning Notebooks with Moose
PDF
FASTTypeScript metamodel generation using FAST traits and TreeSitter project
PDF
Migrating Katalon Studio Tests to Playwright with Model Driven Engineering
PDF
Package-Aware Approach for Repository-Level Code Completion in Pharo
PDF
Evaluating Benchmark Quality: a Mutation-Testing- Based Methodology
PDF
An Analysis of Inline Method Refactoring
PDF
Identification of unnecessary object allocations using static escape analysis
PDF
Control flow-sensitive optimizations In the Druid Meta-Compiler
PDF
Clean Blocks (IWST 2025, Gdansk, Poland)
PDF
Encoding for Objects Matters (IWST 2025)
PDF
Challenges of Transpiling Smalltalk to JavaScript
PDF
Immersive experiences: what Pharo users do!
PDF
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
PDF
Cavrois - an Organic Window Management (ESUG 2025)
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
Micromaid: A simple Mermaid-like chart generator for Pharo
Directing Generative AI for Pharo Documentation
Even Lighter Than Lightweiht: Augmenting Type Inference with Primitive Heuris...
Composing and Performing Electronic Music on-the-Fly with Pharo and Coypu
Gamifying Agent-Based Models in Cormas: Towards the Playable Architecture for...
Analysing Python Machine Learning Notebooks with Moose
FASTTypeScript metamodel generation using FAST traits and TreeSitter project
Migrating Katalon Studio Tests to Playwright with Model Driven Engineering
Package-Aware Approach for Repository-Level Code Completion in Pharo
Evaluating Benchmark Quality: a Mutation-Testing- Based Methodology
An Analysis of Inline Method Refactoring
Identification of unnecessary object allocations using static escape analysis
Control flow-sensitive optimizations In the Druid Meta-Compiler
Clean Blocks (IWST 2025, Gdansk, Poland)
Encoding for Objects Matters (IWST 2025)
Challenges of Transpiling Smalltalk to JavaScript
Immersive experiences: what Pharo users do!
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
Cavrois - an Organic Window Management (ESUG 2025)

Recently uploaded (20)

PDF
sustainability-14-14877-v2.pddhzftheheeeee
PPTX
Modernising the Digital Integration Hub
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PPT
What is a Computer? Input Devices /output devices
PPTX
Tartificialntelligence_presentation.pptx
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
CloudStack 4.21: First Look Webinar slides
PDF
Hybrid model detection and classification of lung cancer
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
Developing a website for English-speaking practice to English as a foreign la...
PDF
Unlock new opportunities with location data.pdf
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPTX
Web Crawler for Trend Tracking Gen Z Insights.pptx
PDF
August Patch Tuesday
sustainability-14-14877-v2.pddhzftheheeeee
Modernising the Digital Integration Hub
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
What is a Computer? Input Devices /output devices
Tartificialntelligence_presentation.pptx
A comparative study of natural language inference in Swahili using monolingua...
A novel scalable deep ensemble learning framework for big data classification...
CloudStack 4.21: First Look Webinar slides
Hybrid model detection and classification of lung cancer
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Getting started with AI Agents and Multi-Agent Systems
NewMind AI Weekly Chronicles – August ’25 Week III
Zenith AI: Advanced Artificial Intelligence
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Developing a website for English-speaking practice to English as a foreign la...
Unlock new opportunities with location data.pdf
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Web Crawler for Trend Tracking Gen Z Insights.pptx
August Patch Tuesday

Native or External?

  • 1. Native or External? Lessons learned implementing cryptography for VisualWorks Martin Kobetic Cincom Smalltalk Engineering ESUG 2011
  • 2. Let's implement SSL! DES, MD5, SHA, RSA, DSA, RC4, X.509, ASN.1, DER, ... * SSL 3.0, RSA, DES, RC4, basic X.509 (RSA only) * DH, DSA, + SSL integration, AES * X.509 on ASN.1, faster RSA (CRT),... * new ASN.1 (read/write), more X.509 * protocols/S (HTTPS, SMTPS,....)
  • 3. What is Cryptography hashes MD5, SHA1, SHA256, ... secret key (symmetric) ciphers AES, DES, RC4,... public key algorithms * signing (RSA, DSA, ECDSA) * encryption (RSA) * key agreement (DH, ECDH)
  • 4. Hashes - Native (MD5 hash: 'Hello') asHexString. buffer := ByteArray new: 16384. hash := SHA new. file := (ObjectMemory imageFilename withEncoding: #binary) readStream. [ [ file atEnd ] whileFalse: [ | read | read := file nextAvailable: buffer size into: buffer startingAt: 1. hash updateWith: buffer from: 1 to: read ]. ] ensure: [ file close ]. hash digest asHexString.
  • 5. Hashes - External buffer := ByteArray new: 16384. hash := Hash new algorithm: 'SHA1'; yourself. file := (ObjectMemory imageFilename withEncoding: #binary) readStream. [ [ file atEnd ] whileFalse: [ | read | read := file nextAvailable: buffer size into: buffer startingAt: 1. hash update: read from: buffer ]. hash finish asHexString ] ensure: [ file close. hash release ].
  • 6. Hashes - Xtreams ((ObjectMemory imageFilename reading hashing: 'SHA1' ) -= 0; close; digest ) asHexString
  • 7. Ciphers - Native message := 'Hello World!' asByteArrayEncoding: #ascii. key := 'Open Sesame!!!!!' asByteArrayEncoding: #ascii. ((ARC4 key: key) encrypt: message) asHexString. cipher := AES key: key. cipher := CipherBlockChaining on: cipher. iv := ByteArray new: 16 withAll: 1. cipher setIV: iv. cipher := BlockPadding on: cipher. (cipher encrypt: message) asHexString
  • 8. Ciphers - Speed megs := 100. buffer := ByteArray new: 1000. time := [ megs * 1000 timesRepeat: [ 1 to: buffer size do: [ :i | buffer at: i put: (buffer at: i) ]] ] timeToRun. megs asFloat / time asSeconds. time := [ self readWriteMegs: megs ] timeToRun. megs asFloat / time asSeconds
  • 9. Ciphers - External buffer := ByteArray new: message size + iv size. cipher := Cipher new. padding := iv size - (message size iv size). padding := ByteArray new: padding withAll: padding. [ | count | cipher algorithm: 'AES' mode: 'CBC' key: key iv: iv encrypt: true. count := cipher update: message size from: message into: buffer. result := buffer copyFrom: 1 to: count. count := cipher update: padding size from: padding into: buffer. result := result, (buffer copyFrom: 1 to: count). count := cipher finishInto: buffer. result, (buffer copyFrom: 1 to: count) ] ensure: [ cipher release ]
  • 10. Ciphers - Xtreams ((( ByteArray new writing encrypting: 'AES' mode: 'CBC' key: key iv: iv ) hashing: 'SHA1' ) write: message; write: padding; close; terminal ) asHexString
  • 11. Public Key - Native keys := RSAKeyGenerator keySize: 1024. keys publicKey. rsa := RSA new privateKey: keys privateKey. rsa useMD5. sig := rsa sign: message.
  • 12. Public Key - External key := PrivateKey RSALength: 1024. [ | digest | digest := (message reading hashing: 'SHA1') -= 0; close; digest. key sign: digest hash: 'SHA1' padding: 'PKCS1' ] ensure: [ key release ]
  • 13. Native - Pros * understanding and know-how * ease of use and deployment * automatically cross platform * easy integration * debugging
  • 14. Native - Cons * maintenance/evolution * security issues * speed * certification * hardware integration * export restrictions
  • 15. External - Pros * development cost (maybe) * evolves for free (hopefully) * speed * certification (possibly) * hardware integration (possibly)
  • 16. External - Cons * platform coverage * integration issues * support * FFI issues * brittleness
  • 17. Summary * seamless use * seamless deployment * platform coverage * capability coverage * extensibility * other constraints * certification/approved implementations * hardware support * performance