Pro Cryptography and Cryptanalysis with C 20 Creating and Programming Advanced Algorithms 1st Edition Marius Iulian Mihailescu pdf download
Pro Cryptography and Cryptanalysis with C 20 Creating and Programming Advanced Algorithms 1st Edition Marius Iulian Mihailescu pdf download
https://ebookmeta.com/product/pro-cryptography-and-cryptanalysis-
with-c-20-creating-and-programming-advanced-algorithms-1st-
edition-marius-iulian-mihailescu-2/
https://ebookmeta.com/product/pro-cryptography-and-cryptanalysis-
with-c23-creating-and-programming-advanced-algorithms-2nd-
edition-marius-iulian-mihailescu-3/
https://ebookmeta.com/product/pro-cryptography-and-cryptanalysis-
with-c23-creating-and-programming-advanced-algorithms-2nd-
edition-marius-iulian-mihailescu-2/
https://ebookmeta.com/product/production-presentation-and-
acceleration-of-educational-research-could-less-be-more-could-
less-be-more/
The Killer s Christmas List 1 EDITION Edition Chris
Frost
https://ebookmeta.com/product/the-killer-s-christmas-
list-1-edition-edition-chris-frost/
https://ebookmeta.com/product/king-of-her-dreams-1st-edition-
karla-doyle/
https://ebookmeta.com/product/incomplete-1st-edition-sloan-
cheryl/
https://ebookmeta.com/product/superficial-fungal-infections-of-
the-skin-1st-edition-archana-singal-chander-grover/
https://ebookmeta.com/product/management-of-chronic-kidney-
disease-2nd-edition-mustafa-arici/
Nature and Nurture in Mental Disorders A Gene
Environment Model A Gene Environment Model 2nd Edition
Joel M D Paris
https://ebookmeta.com/product/nature-and-nurture-in-mental-
disorders-a-gene-environment-model-a-gene-environment-model-2nd-
edition-joel-m-d-paris-2/
Pro Cryptography
and Cryptanalysis
with C++20
Creating and Programming Advanced
Algorithms
—
Marius Iulian Mihailescu
Stefania Loredana Nita
Pro Cryptography and
Cryptanalysis with C++20
Creating and Programming
Advanced Algorithms
Copyright © Marius Iulian Mihailescu and Stefania Loredana Nita 2021, corrected
publication 2021
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Steve Anglin
Development Editor: Matthew Moodie
Editorial Operations Manager: Mark Powers
Cover designed by eStudioCalamar
Cover image by Devin Avery on Unsplash (www.unsplash.com)
Distributed to the book trade worldwide by Apress Media, LLC, 1 New York Plaza, New York, NY 10004,
U.S.A. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit
www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer
Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail booktranslations@springernature.com; for reprint,
paperback, or audio rights, please e-mail bookpermissions@springernature.com.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book’s product page, located at www.apress.com/9781484265857. For more
detailed information, please visit www.apress.com/source-code.
Printed on acid-free paper
To our families.
Table of Contents
About the Authors�������������������������������������������������������������������������������������������������� xiii
Part I: Foundations�������������������������������������������������������������������������������� 1
Chapter 1: Getting Started in Cryptography and Cryptanalysis�������������������������������� 3
Cryptography and Cryptanalysis��������������������������������������������������������������������������������������������������� 4
Book Structure������������������������������������������������������������������������������������������������������������������������������ 5
Internet Resources������������������������������������������������������������������������������������������������������������������������ 9
Forums and Newsgroups������������������������������������������������������������������������������������������������������ 10
Standards������������������������������������������������������������������������������������������������������������������������������������ 11
Conclusion���������������������������������������������������������������������������������������������������������������������������������� 12
References���������������������������������������������������������������������������������������������������������������������������������� 13
v
Table of Contents
Digital Signatures������������������������������������������������������������������������������������������������������������������������ 32
Signing Process��������������������������������������������������������������������������������������������������������������������� 33
Verification Process��������������������������������������������������������������������������������������������������������������� 33
Public-Key Cryptography������������������������������������������������������������������������������������������������������������ 33
Hash Functions��������������������������������������������������������������������������������������������������������������������������� 36
Case Studies������������������������������������������������������������������������������������������������������������������������������� 53
Caesar Cipher Implementation in C++20������������������������������������������������������������������������������ 53
Vigenére Cipher Implementation in C++20��������������������������������������������������������������������������� 55
Conclusions��������������������������������������������������������������������������������������������������������������������������������� 58
References���������������������������������������������������������������������������������������������������������������������������������� 58
viii
Table of Contents
ix
Table of Contents
x
Table of Contents
xi
Table of Contents
Index��������������������������������������������������������������������������������������������������������������������� 463
xii
About the Authors
Marius Iulian Mihailescu, PhD is the CEO of Dapyx Solution Ltd., a company based in
Bucharest, Romania. He is involved in information security- and cryptography-related
research projects. He is a lead guest editor for applied cryptography journals and a
reviewer for multiple publications on information security and cryptography profiles.
He has authored and co-authored more than 30 articles for conference proceedings, 25
articles for journals, and four books. For more than six years he has served as a lecturer
at well-known national and international universities (University of Bucharest, Titu
Maiorescu University, Spiru Haret University of Bucharest, and Kadir Has University,
Istanbul, Turkey). He has taught courses on programming languages (C#, Java, C++,
Haskell) and object-oriented system analysis and design with UML, graphs, databases,
cryptography, and information security. He worked for three years as an IT Officer
at Royal Caribbean Cruises Ltd. where he dealt with IT infrastructure, data security,
and satellite communications systems. He received his PhD in 2014 and his thesis is
on applied cryptography over biometrics data. He holds MSc degrees in information
security and software engineering.
Stefania Loredana Nita, PhD is a software developer and researcher at the Institute for
Computers of the Romanian Academy. Her PhD thesis is on advanced cryptographic
schemes using searchable encryption and homomorphic encryption. At the Institute for
Computers, she works on research and development projects that involve searchable
encryption, homomorphic encryption, cloud computing security, Internet of Things, and
big data. She worked for more than two years as an assistant lecturer at the University of
Bucharest where she taught courses on advanced programming techniques, simulation
methods, and operating systems. She has authored and co-authored more than 25
workpapers for conferences and journals, and has co-authored four books. She is a
lead guest editor for special issues on information security and cryptography such as
Advanced Cryptography and Its Future: Searchable and Homomorphic Encryption. She
has an MSc degree in software engineering and BSc degrees in computer science and
mathematics.
xiii
About the Technical Reviewer
Doug Holland is a Software Engineer and Architect at Microsoft Corporation. He holds
a Master’s degree in software engineering from the University of Oxford. Before joining
Microsoft, he was awarded the Microsoft MVP and Intel Black Belt Developer awards.
xv
Acknowledgments
We would like to thank our editors for their support, our technical reviewer for his
constructive comments and suggestions, the entire team that makes publishing this
book possible, and last but not least, our families for their unconditional support and
encouragement.
xvii
PART I
Foundations
CHAPTER 1
Getting Started in
Cryptography and
Cryptanalysis
Knowledge is one of the most important aspects to consider when designing and
implementing complex systems, such as companies, organizations, military operations,
and so on. Information falling into the wrong hands can be a tragedy and can result
in a huge loss of business or disastrous outcomes. To guarantee the security of
communications, cryptography can be used to encode information in such a way that
nobody will be able to decode it without having the legal right. Many ciphers have been
broken when a flaw has been found in their design or enough computing power has
been applied to break an encoded message. Cryptology, as you will see later, consists of
cryptography and cryptanalysis.
With the rapid evolution of electronic communication, the number of issues raised
by information security significantly increases every day. Messages that are shared over
publicly accessible computer networks around the world must be secured and preserved
and must get the proper security mechanisms to protect against abuse. The business
requirement in the field of electronic devices and their communication consists of
having digital signatures that can be recognized by law. Modern cryptography provides
solutions to all these problems.
The idea for this book started from experiences in several directions: (1)
cryptography courses for students (at the graduate and undergraduate levels) in
computer science at the University of Bucharest and Titu Maiorescu University; (2)
industry experience achieved at national and international companies; (3) ethical
hacking best practices; and (4) security audits. The goal of this book is to present
the most advanced cryptography and cryptanalysis techniques together with their
3
© Marius Iulian Mihailescu and Stefania Loredana Nita 2021
M. I. Mihailescu and S. L. Nita, Pro Cryptography and Cryptanalysis with C++20,
https://doi.org/10.1007/978-1-4842-6586-4_1
Chapter 1 Getting Started in Cryptography and Cryptanalysis
implementations using C++20. This book will offer a practical perspective, giving the
readers the necessary tools to design cryptography and cryptanalysis techniques in
terms of practice. Most of the implementations are in C++20 using the latest features
and improvements of the programming language (see Chapter 6). The book is an
advanced and exhaustive work, offering a comprehensive view of the most important
topics in information security, cryptography, and cryptanalysis. The content of the
book can be used in a wide spectrum of areas by many professionals, such as security
experts with their audits, military experts and personnel, ethical hackers, teachers in
academia, researchers, software developers, software engineers when security and
cryptographic solutions must be implemented in a real business software environment,
professors teaching student courses (undergraduate and graduate level, master’s degree,
professional and academic doctoral degree), business analysts, and many more.
C
ryptography and Cryptanalysis
It is very important to understand the meanings of the main concepts involved in a
secure communication process and to know their boundaries.
4
Chapter 1 Getting Started in Cryptography and Cryptanalysis
The book provides a deep examination of all three aspects from a practical point
of view with references to the theoretical background by illustrating how a theoretical
algorithm should be analyzed for implementation.
B
ook Structure
The book is divided into 23 chapters in three parts (see Table 1-1): Part I: Foundations
(Chapters 1-8), Part II: Pro Cryptography (Chapters 9-16), and Part III: Pro Cryptanalysis
(Chapters 17-23). Figure 1-1 shows how to read the book and what chapters depend on
each other.
The Part I: Foundations (Chapters 1-8) covers, from a beginner to advanced
level and from theoretical to practical, the basic concepts of cryptography (Chapter 2).
Chapter 3 covers a collection of key elements regarding complexity theory, probability
theory, information theory, number theory, abstract algebra, and finite fields and how
they can be implemented using C++20, showing their interaction with the cryptography
and cryptanalysis algorithms.
Chapters 4 and Chapter 5 focus on integer arithmetic and floating-point arithmetic
processing. These chapters are vital because other chapters and algorithms depend on
the content of these chapters. Number representations and working with them via the
memory of the computer can be a difficult task.
In Chapter 6, we discuss the newest features and enhancements of C++20. We
give a presentation on how the new features and enhancements play an important
role in developing cryptography and cryptanalysis algorithms and methods. We cover
three-way comparisons, lambdas in unevaluated contexts, string literals, atomic smart
pointers, <version> headers, ranges, coroutines, modules, and more.
Chapter 7 presents the most important guidelines for securing the coding process,
keeping an important balance between security and usability based on the most
expected scenarios based on trusted code. We cover important topics such as securing
state data, security and user input, security-neutral code, and library codes that expose
the protected resources.
5
Chapter 1 Getting Started in Cryptography and Cryptanalysis
Chapter 8 introduces the cryptography model and services that are used by C++.
We cover important topics like C++ basic implementations, object inheritance, how
cryptography algorithms are implemented, stream design, configuring cryptography
classes, how to choose cryptography algorithms, generating the keys for encryption
and decryption, storing asymmetric keys in a key container, cryptographic signatures,
ensuring data integrity using hash codes and functions, creating and designing
cryptographic schemes, encryption of XML elements with symmetric keys, assuring and
guaranteeing interoperability of the applications between different platforms, such as
Windows, MacOS, UNIX/Linux, and more.
Part II: Pro Cryptography (Chapters 9-16) contains the most important modern
cryptographic primitives. Chapters 9-16 discuss the advanced cryptography topics by
showing implementations and how to approach this kind of advanced topic from a
mathematical background to a real-life environment.
Chapter 9 discusses Cryptography Next Generation (CNG), which is used in the
implementation of the Elliptic Curve Diffie-Hellman (ECDH) algorithm, and how to
realize the necessary cryptographic operations.
Chapter 10 provides an introduction to the Lattice Cryptography Library and how it
works, pointing out the importance of post-quantum cryptography. Implementations of
key exchange protocols proposed by Alkim, Ducas, Poppelmann, and Schwabe [1] are
discussed. We continue our discussion with an instantiation of Chris Peikert’s key exchange
protocol [2]. We point out that the implementation is based on modern techniques for
computing, known as the number theoretic transform (NTT). The implementations apply
errorless fast convolution functions over successions of integer numbers.
Chapter 11 and Chapter 12 present two important cryptographic primitives,
homomorphic and searchable encryption. For searchable encryption (SE), Chapter 11
presents an implementation using C++20 and showing the advantages and disadvantages
by removing the most common patterns from encrypted data. In Chapter 12, we discuss
how to use the SEAL library for fully homomorphic encryption. The implementation is
discussed based on the proposal of Shai Halevi and Victor Shoup in [3].
Chapter 13 covers the issues that are generated during the implementation of (ring)
learning with errors cryptography mechanisms. We give as an example an implementation
of the lattice-based key exchange protocol, a library that is used only for experiments.
Chapter 14 is based on the new concepts behind chaos-based cryptography and how
they can be translated into practice. The chapter generates some new outputs and its
contribution is important for the advancement of cryptography as it is a new topic that
hasn’t received proper attention until now.
6
Chapter 1 Getting Started in Cryptography and Cryptanalysis
Chapter 15 discusses new methods and their implementations for securing big
data environments, big data analytics, access control methods (key management for
access control), attributed-based access control, secure search, secure data processing,
functional encryption, and multi-party computation.
Chapter 16 points out the security issues raised by applications that run in a cloud
environment and how they can be resolved during the designing and implementation
phase.
In Part III: Pro Cryptanalysis (Chapters 17-23), we deal with advanced cryptanalysis
topics and we show how to pass the barrier between theory and practice, and how to think
of cryptanalysis in terms of practice by eliminating the most vulnerable and critical points
of a system or software application in a network or distributed environment.
Starting with Chapter 17 we provide an introduction to cryptanalysis by presenting
the most important characteristics of cryptanalysis.
Chapter 18 shows the important criteria and standards used in cryptanalysis, how
the tests of cryptographic systems are made, the process of selecting cryptographic
modules, cryptanalysis operations, and classifications of cryptanalysis attacks.
In Chapter 19 and Chapter 20, we show how to implement and design linear and
differential and integral cryptanalysis. We focus on techniques and strategies where the
primary role is to show how to implement scripts for attacking linear and differential
attacks.
Chapter 21 presents the most important attacks and how they can be designed
and implemented using C++20. You study the behavior of software applications when
they are exposed to different attacks and you exploit the source code. We also discuss
software obfuscation and show why this is a critical aspect that needs to be taken into
consideration by the personnel involved in implementing the process of the software.
Also, we show how this analysis can lead to machine learning and artificial intelligence
algorithms that can be used to predict future attacks against software applications that
are running in a distributed or cloud environment.
In Chapter 22, we go through the text characterization methods and
implementations. We discuss chi-squared statistics; identifying unknown ciphers; index
of coincidence; monogram, bigram, and trigram frequency counts; quad ram statistics as
a fitness measure; unicity distance; and word statistics as a fitness measure.
Chapter 23 presents the advantages and disadvantages of implementing the
cryptanalysis methods, why they should have a special place when applications are
developed in distributed environments, and how the data should be protected against
such cryptanalysis methods.
7
Chapter 1 Getting Started in Cryptography and Cryptanalysis
8
Chapter 1 Getting Started in Cryptography and Cryptanalysis
I nternet Resources
The Internet offers a significant amount of resources that are very useful regarding the
topics in this book. These resources will help you keep up with progress in the fields:
9
Chapter 1 Getting Started in Cryptography and Cryptanalysis
Also, there are many forums that deal with cryptography topics and news. The most
important are as follows:
10
Chapter 1 Getting Started in Cryptography and Cryptanalysis
• Security forums [6]: They cover vast topics and discussions about
computer security and cryptography.
• TechGenix: Security [7]: One of the most updated forums with
news related to cryptography and information security. The group is
maintained by world-leading security professionals.
• Wilders Security Forums [8]: The forum contains discussions and
news about the vulnerabilities of software applications due to bad
implementations of cryptographic solutions.
• Security Focus [9]: The forum contains a series of discussions about
vulnerabilities raised by the implementations of cryptographic
algorithms.
• Security InfoWatch [10]: The discussions are related to data and
information loss.
• TechRepublic: Security [11]: The forum contains discussions about
practical aspects and methodologies that can be used when software
applications are designed and implemented.
• Information Security Forum [12]: A world-leading forum in the
field of information security and cryptography. The forum contains
conferences plus hands-on and practical tutorials for solving
solutions for security and cryptographic issues.
S
tandards
Many of the cryptographic techniques and implementations described in this book
follow the below standards. These standards have been developed and designed to
cover the management practices and the entire architecture of security mechanisms,
strategies, and services.
The most important standards covered by this book are as follows:
Conclusion
The era in which we are living is one of unimaginable evolution and incredible
technologies that enable the instant flow of information at any time and any place.
The secret consists of the convergence of the computer with networks; this forces the
evolution and development of these incredible technologies from behind.
In this first chapter, we discussed the objectives of the book and its benefits.
We explained the mission of the book, which is to address the practical aspects of
cryptography and information security and its main intention in using the current work.
The systems built upon advanced information technologies have a deep impact on our
lives every day. These technologies are proving to be pervasive and ubiquitous.
12
Chapter 1 Getting Started in Cryptography and Cryptanalysis
The book represents the first practical step of translating the most important
theoretical cryptography algorithms and mechanisms into practice through one of the
most powerful programming languages, C++20.
In this chapter, you learned the following:
• The structure of the book in order to help you follow the content
easier. A roadmap was introduced in order to show the dependencies
of each chapter. Each chapter was presented in detail, pointing out
the main objective.
R
eferences
[1] E. Alkim, L. Ducas, T. Pöppelmann, and P. Schwabe, “Post-
quantum key exchange—a new hope” in 25th {USENIX} Security
Symposium ({USENIX} Security 16) (pp. 327-343). 2016.
[2] C. Peikert, “Lattice cryptography for the internet” in International
workshop on post-quantum cryptography (pp. 197-219). Springer,
Cham. October, 2014.
13
Chapter 1 Getting Started in Cryptography and Cryptanalysis
14
CHAPTER 2
Cryptography
Fundamentals
Cryptographic history is incredibly long and fascinating. A great and comprehensive
reference is The Code Book: The Secrets Behind Codebreaking [1] published in 2003,
which provides a non-technical history of cryptography. In the book, the story of
cryptography begins around 2000 BC, when the Egyptians used it for the first (known)
time, and ends with our era. It presents the main aspects of cryptography and hiding
information for each period that is covered and describes cryptography’s great
contribution to both World Wars. Often, the art of cryptography is correlated with
diplomacy, the military, and governments because its purpose is to keep safe sensitive
data such as strategies or secrets regarding national security.
A crucial development in modern cryptography is the workpaper New Directions
in Cryptography [2] proposed by Diffie and Hellman in 1976. The paper introduced a
notion that changed how cryptography was seen: public-key cryptography. Another
important contribution in this paper was the innovative way of exchanging keys; the
security of the presented technique was based on the hardness assumption (basically,
through the hardness assumption we refer to a problem that cannot be solved efficiently)
of the discrete logarithm problem. Although the authors did not propose a practical
implementation for their public-key encryption scheme, the idea was presented very
clearly and started to get attention from the international cryptography community.
The first implementation of a public-key encryption scheme was made in 1978 by
Rivest, Shamir, and Adleman, who proposed and implemented their encryption scheme,
known nowadays as RSA [3]. The hardness assumption in RSA is the factoring of large
integers. By looking in parallel at integer factorization for RSA and Shor’s algorithm,
note that Shor’s Algorithm will run in polynomial time for quantum computers. This
represents a significant challenge for any cryptographer who is using the hardness
15
© Marius Iulian Mihailescu and Stefania Loredana Nita 2021
M. I. Mihailescu and S. L. Nita, Pro Cryptography and Cryptanalysis with C++20,
https://doi.org/10.1007/978-1-4842-6586-4_2
Chapter 2 Cryptography Fundamentals
assumption for factoring large integers. The increasing applications and interest in the
factoring problem led to new factoring techniques. Important advances in this area
were made in 1980, but none of the proposed techniques brought improvements to the
security of RSA. Another important class of practical public-key encryption schemes
was designed by ElGamal [4] in 1985. It was based on the hardness assumption of the
discrete logarithm problem.
Another crucial contribution to public-key cryptography was the digital signature,
which was adopted by the international standard ISO/IEC 9796 in 1991 [5]. The basis of
the standard is the RSA public-key encryption scheme. A powerful scheme for digital
signatures based on the discrete logarithm hardness assumption is the Digital Signature
Standard, adopted by the United States Government in 1994.
Nowadays, the trends in cryptography include designing and developing new public-
key schemes, adding improvements to the existing cryptographic mechanisms, and
elaborating on security proofs.
The objective of this book is to provide a view of the latest updates of the
principles, techniques, algorithms, and implementations of the most important
aspects of cryptography in practice. We will focus on the practical and applied
aspects of cryptography. You will be warned about difficult subjects and those that
present issues. You will be guided to a proper references where you will find best
practices and solutions. Most of the aspects presented in the book will be followed by
implementations. This objective is to not obscure the real nature of cryptography. The
book offers strong material for both implementers and researchers. The book describes
algorithms and software systems with their interactions.
16
Chapter 2 Cryptography Fundamentals
mechanisms have been proposed. The objectives regarding information security may be
accomplished by applying mathematical algorithms or work protocols on information
that needs to be protected and additionally by following specific procedures and laws.
An example of physical document protection is a sealed envelope (the mechanism of
protection) that covers the letter (the information that needs to be protected) delivered
by an authorized mail service (the trusted party). In this example, the protection
mechanism has its limitations, but the technical framework has rigorous rules, through
which any entity that opens the envelope without the right to so may be punished. There
are situations in which the physical paper itself, which contains the information that
needs to be protected, may have special characteristics that certify the originality of the
data/information. For example, to refrain from the forging of bank notes, paper currency
has special ink and matter.
17
Chapter 2 Cryptography Fundamentals
From a conceptual point of view, how the information is manipulated did not change
overmuch. We are considering here storing, registering, interpreting, and recording
data. However, a manipulation that changed significantly is copying and modifying
the information. An important concept in information security is the signature, which
represents the foundation for more processes, such as non-repudiation, data origin
authentication, identification, and witnessing.
To achieve the security of information in electronic communication, the
requirements introduced by the legal and technical skills should be followed. On the
other hand, it is not guaranteed that the above objectives of protection are fulfilled
accordingly. The technical part of the information security is assured by cryptography.
Cryptography is the field that studies the mathematical techniques and tools
that are connected to information security such as confidentiality, integrity (data),
authentication (entity), and the origin of the authentication. Cryptography not only
provides the security of the information but also a specific set of techniques.
18
Chapter 2 Cryptography Fundamentals
C
ryptography Goals
From the security objectives presented in Table 2-1, the following represent a basis from
which can be derived the others:
19
Chapter 2 Cryptography Fundamentals
One of the main goals of cryptography is to fulfill the four objectives described above
on both sides, theory and practice.
C
ryptographic Primitives
During the book, we will present several fundamental cryptographic tools, called
primitives. Examples of primitives are encryption schemes (Definitions 2.5 and 2.8),
hash functions (Definition 2.9), and schemes for digital signatures (Definition 2.6).
Figure 2-1 shows a schematic description of these primitives and the relation between
them. We will use many of the cryptographic primitives during the book, and we will
provide practical implementations every time we use them. Before using them in real-
life applications, the primitives should be subjected to an evaluation process in order to
check if the below criteria are fulfilled:
• Operation methods: When the primitives are used, they need different
inputs and have different ways of working, resulting in different
characteristics. In these situations, the primitives provide very different
functionality that will depend on the mode of operation.
20
Chapter 2 Cryptography Fundamentals
The application and the available resources give importance to each of the above
criteria.
Cryptography may be seen as an art practiced by professionals and specialists who
proposed and developed ad-hoc techniques whose purpose was to fulfill important
information security requirements. In the last few decades, cryptography has suffered
21
Chapter 2 Cryptography Fundamentals
the transition from art to science and discipline. Nowadays, there are dedicated
conferences and events in many fields of cryptography and information security.
There are also international professional associations, such as the International
Association for Cryptologic Research (IACR), whose aim is to promote the best results
of research in the area.
This book is about cryptography and cryptanalysis, implementing algorithms and
mechanisms using C++ with respect to standards.
22
Chapter 2 Cryptography Fundamentals
representation of the two sets A, B and the function f. The preimage of element 2 is a.
The image of f is {1, 2, 4}.
Example 2.4. ( function) Let’s consider set A = {1, 2, 3, ……, 10} and consider f to be
the rule that for each a ∈ A, f(a) = ra, where ra represents the remainder when a2 is being
divided by 11.
f (1) = 1 f ( 6 ) = 3
f ( 2) = 3 f (7 ) = 5
f ( 3) = 9 f ( 8 ) = 9
f ( 4) = 5 f (9) = 4
f ( 5 ) = 3 f (10 ) = 1
Figure 2-2. Function f from a set A formed from three elements to a set B formed
from five elements
23
Chapter 2 Cryptography Fundamentals
The scheme represents the main fundamental tool for thinking of a function (you
can find it the literature as the functional diagram) as depicted in Figure 2-2, and each
element from the domain A has precisely one arrow originated from it. For each element
from codomain B we can have any number of arrows as being incident to it (including
also zero lines).
Example 2.5. ( function) Let’s consider the following set defined as A = {1, 2, 3, …, 1050}
and consider the f to be the rule f (a) = ra, where ra represents the remainder in the case
when a2 is divided by 1050 + 1 for all a ∈ A. In this situation, it is not feasible to write down
f explicitly as in Example 2.4. This being said, the function is completely defined by the
domain and the mathematical description that characterize the rule f.
O
ne-to-One Functions
Definition 2.6 [18]. We will consider a function or transformation as 1 − 1 (one-to-one)
if each of the elements that can be found within the codomain B is represented as the
image of at most one element in the domain A.
Definition 2.7 [18]. Let’s consider that a function or transformation is onto if each of
the elements found within the codomain B represents the image of at least one element
that can be found in the domain. At the same time, function f : A → B is known as being
onto if Im(f) = B.
Definition 2.8 [18]. Let’s consider a function f : A → B to be considered 1 − 1 and
Im(f) = B. Then the function f is called bijection.
Conclusion 2.9 [18]. If f : A → B is considered 1 − 1, then f : A → Im (f) represents the
bijection. In special cases, if f : A → B is represented as 1 − 1, and A and B are represented
as finite sets with the same size, then f represents a bijection.
Using the scheme and its representation, if f is a bijection, then each element from
B has exactly one line that is incidental with it. The functions in Examples 2.3 and 2.4
do not represent bijections. As you can see in Example 2.3, element 3 doesn’t have the
image of any other element that can be found within the domain. In Example 2.4, each
element from the codomain is identified with two preimages.
Definition 2.10 [18]. If f is a bijection from A to B, then it is a quite simple matter to
define a bijection g from B to A as follows: for each b ∈ B, we define g(b) = a where a ∈ A
and f(a) = b. The function g is obtained from f and it is called inverse function of f and it
denoted as g = f −1.
24
Chapter 2 Cryptography Fundamentals
25
Chapter 2 Cryptography Fundamentals
Figure 2-3. f represents a bijection and its inverse g is formed by reversing the sense of
the arrows. The domain of g is represented by B and the codomain is A.
Note that if f is a bijection, f −1 is also a bijection. The bijections in cryptography are
tools used for message encryption. The inverse transformations are used for decryption.
The main condition for decryption is for transformations to be bijections.
O
ne-Way Functions
In cryptography there are a certain types of functions that play an important role. Due to
the rigor, a definition for a one-way function is given as follows.
Definition 2.12 [18]. Let’s consider a function f from a set A to a set B that is called a
one-way function if f(a) proves to be simple and easy to be computed for all a ∈ A but for
“essentially all” elements b ∈ Im (f) it is computationally infeasible to manage to find any
a ∈ A in such way that f(a) = b.
Note 2.13 [18]. This note represents some additional notes and clarifications of the
terms used in Definition 2.12.
2. The words essentially all stand for the idea that there are a couple
of values b ∈ B for which it is easy to find an a ∈ A in such way
that b = f(a). As an example, one may compute b = f(a) for a small
number of a values and then for these, the inverse is known by
a table look-up. A different way to describe this property of a
one-way function is as follows: for any random b ∈ Im (f) it is
computationally feasible to have and find any a ∈ A in such way
that f(a) = b.
The following examples will show the concept behind a one-way function.
Example 2.14. (one-way function) Consider A = {1, 2, 3, …, 16} and let’s define f(a) = ra
for all the elements a ∈ A where ra represents the remainder when 3x will be divided
with 17.
a 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
f(a) 3 9 10 13 5 15 11 16 14 8 7 4 12 2 6 1
26
Chapter 2 Cryptography Fundamentals
Let’s assume that we have a number situated between 1 and 16. We can see that
is very easy to find the image of it under f. Without having the table in front of you, for
example, for 7 it is hard to find a given that f(a) = 7. If the number that you are given is 3,
then is quite easy to see that a = 1 is what you actually need.
Remember that this example is focused on very small numbers. The key thing here is
that the amount of effort to measure f(a) is different than the amount of work in finding
a given f(a). Also for large numbers, f(a) can be efficiently computed using the square-
and-multiply algorithm [20], where the process of finding a from f(a) is harder to find.
Example 2.15 [18]. (one-way function) A prime number is defined as a positive
integer. The integer is bigger than 1 and its positive integers divisors are 1 and
itself. Let’s take into consideration primes p = 50633 and q = 58411, compute
n = pq = 50633 · 58411 = 2957524163, and consider A = {1, 2, 3, …, n − 1}. We will
define a function f on A by f(a) = ra for each a ∈ A, where ra represents the remainder
when x3 is divided by n. For example, let’s consider f(2489991 = 1981394214 since
24899913 = 5881949859 · n + 1981394214. Computing f(a) represents a simple thing to be
done, but reversing the procedure is quite difficult.
27
Chapter 2 Cryptography Fundamentals
P
ermutations
Permutation represents functions that are in cryptographic constructs.
Definition 2.17 [18]. Consider S to be a finite set formed of elements. A permutation
p on S represents a bijection as defined in Definition 2.8. The bijection is represented
from S to itself, p : S → S.
Example 2.18 [18]. This example represents a permutation example. Let’s consider
the following permutation: S = {1, 2, 3, 4, 5}. The permutation p : S → S is defined as
p (1) = 2, p ( 2 ) = 5, p ( 3) = 4, p ( 4 ) = 2, p ( 5 ) = 1
æ1 2 3 4 5ö
p=ç ÷,
è 3 5 4 21 ø
in which the top row in the array is represented by the domain and the bottom row is
represented by the image under p as mapping.
Since the permutations are bijections, they have inverses. If the permutation is
written as an away (second form), its inverse can be easily found by interchanging the
rows in the array and reordering the elements from the new top row and the bottom row
accordingly. In this case, the inverse of p is defined as follows:
æ1 2 3 4 5ö
p -1 = ç ÷
è 5 4 13 2 ø
Example 2.19 [18]. This example represents a permutation example. Let’s consider
A to be the set of integers {0, 1, 2, …, p · q − 1} where p and q represent two distinct large
primes. We need to suppose also that neither p − 1 nor q − 1 can be divisible by 3. The
function p(a) = ra, in which ra represents the remainder when a3 is divided by pq, can be
demonstrated and shown as being the inverse perumutation. The inverse permutation is
computationally infeasible by the computers of today, unless p and q are known.
I nvolutions
Involutions are known as functions having their own inverses.
28
Chapter 2 Cryptography Fundamentals
Definition 2.20 [18]. Let’s consider a finite set S and f defined as a bijection S to S,
noted as f : S → S. In this case, the function f will be noted as an involution if f = f −1.
Another way of defining this is f ( f (a)) = a for any a ∈ S.
Example 2.21 [18]. This example represents an involution case. Figure 2-4 shows
an example of involution. Note that if j represents the image of i, then i represents the
image of j.
• is a set known as the message space. The message space has the
strings of symbols from an alphabet, . As an example, may
have binary strings, English text, French text, etc.
29
Chapter 2 Cryptography Fundamentals
• In the above definition, the encryption key e and the decryption key d
form a pair, usually noted as (e, d). In symmetric encryption schemes,
e and d are the same, while in asymmetric (or public-key) encryption
schemes they are different.
30
Chapter 2 Cryptography Fundamentals
• The entity (party) is that component that works with the information:
sending, receiving, manipulating it. The entities/parties from
Figure 2-5 are Alice, Bob, and Oscar. However, in real applications,
the entities are not necessarily people; they may be authorities or
computers, for example.
1
Alice and Bob. Available online: https://en.wikipedia.org/wiki/Alice_and_Bob
31
Discovering Diverse Content Through
Random Scribd Documents
"Neither justice nor post-office employee. Say no more on that
point, uncle."
"I don't know what puts that into your head, father," declared the
poet. "Do you suppose that I propose to myself never to be anything
more than Segundo García, the lawyer's son? If you do, you are
greatly mistaken. You may be very anxious to be rid of the burden of
supporting me, but you are not half as anxious as I am to relieve
you of it."
"Well, then, what are you waiting for? Your uncle is proposing a
variety of things to you and none of them suits you. Do you want to
begin by being Minister?"
"You will take care of the rest. Yes, yes, you say well. You will
draw upon me for little sums, eh? like your brother in the Philippine
Islands. Let me tell you for your guidance, then, that you needn't do
so. I didn't steal what I have, and I don't coin money."
"No," said the lawyer, calming down. "Provided you exact no more
sacrifices from me."
"Directly."
"They are just behind, not two steps off, as one might say. In
Count de Vilar's carriage, in the barouche. On the Señora's account.
The luggage is here. And they paid for the seats as if they had
occupied them."
It was not long before the measured trot of Count de Vilar's pair
of horses was heard and the open carriage, of an old-fashioned
style, rolled majestically into the plaza. Reclining on the back seat
was a man enveloped, notwithstanding the heat, in a cloth cloak; at
his side sat a lady in a gray linen duster, the fanciful brim of her
traveling-hat standing out sharply against the pure blue of the sky.
In the front seat sat a little girl of some ten years and a
mademoiselle, a sort of transpyrenean nursery governess. Segundo,
who had kept in the background at the arrival of the diligence, this
time was less stubborn and the hand which, covered with a long
Suède glove, was stretched out in quest of a support, met with the
energetic and nervous pressure of another hand. The Minister's lady
looked with surprise at the gallant, gave him a reserved salutation
and, taking the arm Agonde offered her, walked quickly into the
apothecary's.
At last the commotion calmed down, the great man entering the
apothecary's, followed by García, Genday, the Alcalde, and Segundo.
"Nieves, take that morsel of cake for my sake; you will find it
excellent; only we have the secret of making it."
"No," answered the girl, in a clear and affected voice. "In Madrid
we eat crullers and doughnuts with our chocolate."
"It is the fashion here to take sponge-cake with it, not crullers.
Take that one on the top, that brown one. That's nothing, a bird
could eat it."
"And you will rob them again now," exclaimed Clodio Genday
gayly. "We must tell the master of Las Vides to put a guard over the
vine of Jaen."
The jest was received with demonstrations of hilarity, and the girl
laughed with her shrill laugh at the idea of her papa robbing a
grapevine. Segundo only smiled. His eyes were fixed on Don
Victoriano, and he was thinking of what his life had been. He went
over in his mind the history of the great man: At Segundo's age Don
Victoriano, too, was an obscure lawyer, buried in Vilamorta, eager to
break from the shell. He had gone to Madrid, where a celebrated
jurisconsult had taken him as his assistant. The jurisconsult was a
politician, and Victoriano followed in his footsteps. How did he begin
to prosper? This period was shrouded in obscurity. Some said one
thing, some another. Vilamorta found him, when it least expected, its
candidate and representative. Once in Congress Don Victoriano's
importance grew steadily, and when the Revolution of September
came it found him in a sufficiently exalted position to be improvised
a minister. The brief ministry gave him neither time to wear out his
popularity nor to give proof of special gifts, and, with his prestige
almost intact, the Restoration admitted him as a member of a
fusionist cabinet. He had just laid down the portfolio and come to re-
establish his shattered health in his native place, where his influence
was strong and incontestible, thanks to his alliance with the
illustrious house of Mendez de las Vides. Segundo asked himself if a
lot like Don Victoriano's would satisfy his aspirations. Don Victoriano
had wealth—stocks in banks and shares in railways among whose
directors the name of the able jurisconsult figured. Our versifier
raised his eyebrows disdainfully and glanced at the Minister's wife;
that graceful beauty certainly did not love her lord. She was the
daughter of a younger son of the house of Las Vides—a magistrate;
she had probably married her husband, allured by his position. No;
most assuredly the poet did not envy the politician. Why had this
man risen to the eminent position he occupied? What extraordinary
gifts did he possess? A diffuse parliamentary orator, a passive
minister, with some forensic ability—sum total, a mediocrity.
"For Doas, man. I have not a minute to spare." And saying this
the doctor alighted from his mule, which he tied to an iron ring
fastened in the wall.
"But what is the matter with him? Let us hear. For as to being
sick, he is that."
"He has—a new disease—a very strange one, one of the latest
fashion." And Agonde smiled maliciously.
"New?"
"I know, I know," he said emphatically. "And the waters here, and
some others in France, are the only cure for that disease. If he
drinks a few glasses from the spring, he will be himself again."
"What should she say of it, man? Probably she does not know
that it is serious."
"The Señora—"
"No, friend Saturnino, nor shall we take it, with your permission,
until we return. Don't trouble yourself on our account. Victoriniña
has ransacked your pantry—your closets——"
The child half opened a handkerchief which she held by the four
corners, disclosing a provision of bread, cake, and the cheese of the
country.
"At least let me bring you a whole cheese. I will go see if there is
not some fresh bread, just out of the oven——"
Don Victoriano objected—let him not be deprived of the pleasure
of going to breakfast in the poplar-grove near the spring, just as he
had done when a boy. Agonde remarked that those articles of food
were not wholesome for him, to which Tropiezo, scratching the tip of
his ear, responded sceptically:
"I would send you to Carlsbad or to Vichy, but those waters are
not always beneficial. At times they hasten the natural course of a
disease. Rest for a time, and diet yourself—we will see how you are
when you return in the autumn." And what a look Sanchez del
Abrojo put on when he said this! An impenetrable, sphinx-like
expression. The positive assertion of Tropiezo awoke tumultuous
hopes in Don Victoriano's breast. This village practitioner must know
a great deal from experience, more perhaps than the pompous
doctors of the capital.
They took the path toward the grove. Vilamorta, naturally given
to early rising, was more full of activity at this hour than in the
afternoon. The shops were open, the baskets of the fruit-venders
were already filled with fruit. Cansin walked up and down his
establishment with his hands in his pockets, affecting to have
noticed nothing, so as not to be obliged to bid good-morning to
Agonde and acknowledge his triumph. Pellejo, covered with flour,
was haggling with three shopkeepers from Cebre, who wanted to
buy some of his best wheat. Ramon, the confectioner, was dividing
chocolate into squares on a large board placed on the counter and
rapidly stamping them with a hot iron before they should have time
to cool.
The morning was cloudless and the sun was already unusually
hot. The party, augmented by García and Genday, walked through
orchards and cornfields until they reached the entrance to the walk.
Don Victoriano uttered an exclamation of joy. It was the same
double row of elms bordering the river, the foaming and joyous
Avieiro, that ran on sparkling in gentle cascades, washing with a
pleasant murmur the rocks, worn smooth by the action of the
current. He recognized the thick osier plantations; he remembered
all his longings of the day before and leaned, full of emotion, on the
parapet of the walk. The scene was almost deserted; half a dozen
melancholy and bilious-looking individuals, visitors to the springs,
were walking slowly up and down, discussing their ailments in low
tones, and eructating the bicarbonate of the waters. Nieves, leaning
back on a stone bench, gazed at the river. The child touched her on
the shoulder, saying:
"He is not looking this way. Ah! now he is looking. Salute him,
you, mamma. He is taking off his hat, he is going to fall! There! now
he is safe."
Don Victoriano descended the stone steps leading to the spring.
The abode of the naiad was a humble grotto—a shed supported on
rough posts, a small basin overflowing with the water from the
spring, some wretched hovels for the bathers, and a strong and
sickening odor of rotten eggs, caused by the stagnation of the
sulphur water, were all that the fastidious tourist found there.
Notwithstanding this, Don Victoriano's soul was filled with the purest
joy. In this naiad he beheld his youth, his lost youth—the age of
illusions, of hopes blooming as the banks of the Avieiro. How many
mornings had he come to drink from the fountain, for a jest, to wash
his face with the water, which enjoyed throughout the country the
reputation of possessing extraordinary curative virtue for the eyes.
Don Victoriano stretched out his hands, plunged them into the warm
current, feeling it slip through his fingers with delight, and playing
with it and caressing it as one caresses a loved being. But the
undulating form of the naiad escaped from him as youth escapes
from us—without the possibility of detaining it. Then the ex-Minister
felt a thirst awaken in him to drink the waters. Beside him on the
edge of the basin was a glass; and the keeper, a poor old man in his
dotage, presented it to him with an idiotic smile. Don Victoriano
drank, closing his eyes, with indescribable pleasure, enjoying the
mysterious water, charmed by the magic arts of memory. When he
had drained the glass he drew himself up and ascended the stairs
with a firm and elastic step. Victoriniña, who was breakfasting on
bread and cheese in the avenue, was astonished when her father
took a piece of bread from her lap, saying gayly:
Señor de las Vides was a little old man as dry as a vine branch.
His carefully shaven cheeks, his thin lips and aristocratically pointed
nose and chin, his shrewd, kind eyes, surrounded by innumerable
crows' feet, his intellectual profile, his beardless face, called loudly
for the curled wig, the embroidered coat and the gold snuff-box of
the Campomanes and Arandas. With his delicate and expressive
countenance the countenance of Primo Genday contrasted strongly.
The steward's complexion was white and red, he had the fine and
transparent skin, showing the full veins underneath, of those who
are predisposed to hemiplegy. His eyes were of a greenish color, one
of them being attached, as it were, to the lax and drooping lid, while
the other rolled around with mischievous vivacity. His silvery curls
gave him a distant resemblance to Louis Philippe, as he is
represented on the coins which bear his effigy.
"And they are bringing the alguazil's horse for Don Victoriano!"
exclaimed the tobacconist. "Tricky as the very devil! There will be a
scene. When you rode him, Segundo, did he play you no trick?"
The travelers were now coming out of the house, and the
cavalcade began to form. The ladies seated themselves in their side-
saddles and the men settled their feet in their stirrups. Then the
scene predicted by the tobacconist took place, to the great scandal
and the further delay of the party. As soon as the alguazil's nag
became aware of the presence of a female of his race he began to
snuff the air excitedly, neighing fiercely. Don Victoriano gathered up
the reins, but, before the animal had felt the iron in his mouth, he
became so unmanageable, first rearing, then kicking violently, and
finally turning his head around to try to bite his rider's legs, that Don
Victoriano, somewhat pale, thought it prudent to dismount. Agonde,
furious, dismounted also.
"How are you doing, Victoriniña?" he said to the child. "Are you
comfortable?"
"I warrant you would rather ride on my horse. If you are not
afraid I will take you before me."
"And tell me, García, why don't you address the child as thou?
You treat her with so much ceremony! You will make her fancy she is
a young lady already."
Nieves looked with lively curiosity at the young man and then
hastily turned her glance aside, remembering the quick and nervous
hand-pressure of the day before, when she was alighting from the
carriage. For the second time in the space of a few hours this young
man had surprised her. Nieves led an extremely regular life in Madrid
—the life of the middle classes, in which all the incidents are
commonplace. She went to mass and shopped in the morning; in the
afternoon she went to the Retiro, or made visits; in the evening she
went to her parents' house or to the theater with her husband; on
rare occasions to some ball or banquet at the house of the Duke of
Puenteanchas, a client of Don Victoriano's. When the latter received
the portfolio it made little change in Nieves' way of life. She received
a few more salutations than before in the Retiro; the clerks in the
shops were more attentive to her; the Duchess of Puenteanchas said
some flattering things to her, calling her "pet," and here ended for
Nieves the pleasure of the ministry. The trip to Vilamorta, the
picturesque country of which she had so often heard her father
speak, was a novel incident in her monotonous life. Segundo
seemed to her a curious detail of the journey. He looked at her and
spoke to her in so odd a way. Bah, fancies! Between this young man
and herself there was nothing in common. A passing acquaintance,
like so many others to be met here at every step. So the pines sang,
did they? A misfortune for Gayarre! And Nieves smiled graciously,
dissembling her strange thoughts and went on asking questions, to
which Segundo responded in expressive phrases. Night was
beginning to fall. Suddenly, the cavalcade, leaving the highroad,
turned into a path that led among pine groves and woods. At a turn
of the path could be seen the picturesque dark stone cross, whose
steps invited to prayer or to sentimental reverie. Agonde stopped
here and took his leave of the party, and Segundo followed his
example.
"Segundo."
"How silent you are, my boy! What do you think of the Minister?"
"What would you have me think of him?"
"And the Señora? Come, you have noticed her, I warrant. She
wears black silk stockings, like the priests. When she was mounting
the donkey——"
The nag galloped for half a league or so, urged by his rider's
whip. As they drew near the canebrake by the river, Segundo
slackened his horse's gallop to a very slow walk. It was now almost
dark and the cool mists rose, moist and clinging, from the bosom of
the Avieiro. Segundo remembered that it was two or three days
since he had put his foot in Leocadia's house. No doubt the
schoolmistress was now fretting herself to death, weeping and
watching for him. This thought brought sudden balm to Segundo's
wounded spirit. How tenderly Leocadia loved him! With what joy did
she welcome him! How deeply his poetry, his words, moved her! And
he—why was it that he did not share her ardor? Of this exclusive,
this absolute, boundless love, Segundo had never deigned to accept
even the half; and of all the tender terms of endearment invented by
the muse he chose for Leocadia the least poetical, the least
romantic; as we separate the gold and silver in our purse from the
baser coin, setting aside for the beggar the meanest copper, so did
Segundo dispense with niggard hand the treasures of his love. A
hundred times had it happened to him, in his walks through the
country, to fill his hat with violets, with hyacinths and branches of
blackberry blossoms, only to throw them all into the river on
reaching the village, in order not to carry them to Leocadia.
VII.
While she distributed their tasks among the children, saying to
one, "Take care to make this hem straight," to another, "Make this
seam even, the stitch smaller," to a third, "Use your handkerchief
instead of your dress," and to still another, "Sit still, child, don't
move your feet," Leocadia cast a glance from time to time toward
the plaza in the hope of seeing Segundo pass by. But no Segundo
was to be seen. The flies settled themselves to sleep, buzzing, on
the ceiling; the heat abated; the afternoon came, and the children
went away. Leocadia felt a profound sadness take possession of her
and, without waiting to put the house in order, she went to her room
and threw herself on the bed.
The glass door was pushed gently open, and some one entered
softly.
"No, child."
"Don't go away. How do you feel to-day? Have you any pain?"
Leocadia sat up in the bed and, taking the child's head between
her hands, looked at him with a mother's hungry look. Minguitos'
face was long and of a melancholy cast; the prominent lower jaw
was in keeping with the twisted and misshapen body that reminded
one of a building shaken out of shape by an earthquake or a tree
twisted by a hurricane. Minguitos' deformity was not congenital. He
had always been sickly, indeed, and it had always been remarked
that his head seemed too heavy for his body, and that his legs
seemed too frail to support him. Leocadia recalled one by one the
incidents of his childhood. At five years old the boy had met with an
accident—a fall down the stairs; from that day he lost all his
liveliness; he walked little and never ran. He contracted a habit of
sitting Turkish fashion, playing marbles for hours at a time. If he
rose his legs soon warned him to sit down again. When he stood, his
movements were vacillating and awkward. When he was quiet he
felt no pain, but when he turned any part of his body, he
experienced slight pains in the spinal column. The trouble increased
with time; the boy complained of a feeling as if an iron band were
compressing his chest. Then his mother, now thoroughly alarmed,
consulted a famous physician, the best in Orense. He prescribed
frictions with iodine, large doses of phosphates of lime, and sea-
bathing. Leocadia hastened with the boy to a little sea-port. After
taking two or three baths, the trouble increased; he could not bend
his body; his spinal column was rigid and it was only when he was in
a horizontal position that he felt any relief from his now severe
pains. Sores appeared on his skin, and one morning when Leocadia
begged him with tears to straighten himself, and tried to lift him up
by the arms, he uttered a horrible cry.
"Malpocadiño. Who loves you? say, who loves you dearly? Who?"
"You don't love me, mamma. You don't love me," the boy
returned, half-smiling, leaning his head with delight on the bosom
that had sheltered his sad childhood. The mother, meantime, wildly
kissed his hair, his neck, his eyes—as if to make up for lost time—
lavishing upon him the honeyed words with which infants are
beguiled, words profaned in hours of passion, which overflowed in
the pure channel of maternal love.
"What?"
"But what was the favor you were going to ask me?"
Saying this, she pushed the boy away from her, and sprang from
the bed. In the hall outside almost at the same moment was heard a
firm and youthful step. Leocadia trembled, and turning to Minguitos,
stammered:
"Where?"
"To Las Vides, of course. I hear they intend to have a great deal
of company."
"Yes; they have given me a pressing invitation, but I shall not go.
Uncle Clodio insists upon it that I ought to cultivate the friendship of
Don Victoriano so that he may be of use to me in Madrid and help
me to get a position there. But, child, to go and play a sorry part is
not to my liking. This suit is the best I have, and it is in last year's
fashion. If they play tresillo or give tips to the servants—and it is
impossible to make my father understand this—and I shall not try to
do so: God forbid. So that they shall not catch a sight of me in Las
Vides."
"Give it to me, I will clean it. Put more wood on the fire; it is
going out and the beefsteak will be spoiled." And so saying Leocadia
washed the coffee-pot, cleaning the filter with a knitting-needle, and
put some fresh water down to boil in a new saucepan, throwing
more wood on the fire.
Leocadia, who was slicing some potatoes for the beefsteak, paid
no attention to her. When she had cut up as many as she judged
necessary, she washed her hands hastily in the jar of the drain, full
of dirty water, on whose surface floated large patches of grease. She
then hurried to the parlor where Segundo was waiting for her, and
soon afterward Flores brought in the supper, which they ate, seated
at a small side-table. By the time they had got to the coffee
Segundo began to be more communicative. This coffee was what
Leocadia most prided herself on. She had bought a set of English
china, an imitation lacquer-box, a vermeil sugar-tongs and two small
silver spoons, and she always placed on the table with the coffee a
liquor-stand, supplied with cumin, rum, and anisette. At the third
glass, of cumin, seeing the poet amiable and propitious, Leocadia
put her arm around his neck. He drew back brusquely, noticing with
strong repulsion the odor of cooking and of parsley with which the
garments of the schoolmistress were impregnated.