Browse Source

migration from svn

master
Nicolas Massé 6 years ago
commit
86675018a8
  1. 22
      doc/Makefile
  2. 1
      doc/doc-dpa-ensi/Makefile
  3. 1
      doc/doc-dpa-ensi/docbook
  4. 1
      doc/doc-dpa-ensi/files
  5. 1
      doc/doc-dpa-ensi/fop.xconf
  6. 1
      doc/doc-dpa-ensi/img
  7. 1
      doc/doc-dpa-ensi/main.xml
  8. 272
      doc/doc-dpa-ensi/xsl/fo.xsl
  9. 1
      doc/doc-dpa-ensi/xsl/html-chunked.xsl
  10. 1
      doc/doc-dpa-ensi/xsl/html-onepage.xsl
  11. 1
      doc/doc-dpa-ensi/xsl/xhtml-chunked.xsl
  12. 1
      doc/doc-dpa-ensi/xsl/xhtml-onepage.xsl
  13. 1
      doc/doc-dpa/Makefile
  14. 1
      doc/doc-dpa/docbook
  15. 1
      doc/doc-dpa/fop.xconf
  16. BIN
      doc/doc-dpa/img/dpa1.png
  17. BIN
      doc/doc-dpa/img/dpa2.png
  18. BIN
      doc/doc-dpa/img/dpa3.png
  19. BIN
      doc/doc-dpa/img/flowcert.png
  20. 1
      doc/doc-dpa/img/gantt.png
  21. BIN
      doc/doc-dpa/img/leak.png
  22. BIN
      doc/doc-dpa/img/logos/ensi-vertical-long.png
  23. BIN
      doc/doc-dpa/img/logos/ensi-vertical.png
  24. BIN
      doc/doc-dpa/img/logos/ensi.png
  25. BIN
      doc/doc-dpa/img/logos/ingenico.jpg
  26. BIN
      doc/doc-dpa/img/organisation.png
  27. BIN
      doc/doc-dpa/img/precharged-bus.png
  28. BIN
      doc/doc-dpa/img/side-channels.png
  29. BIN
      doc/doc-dpa/img/spa.png
  30. BIN
      doc/doc-dpa/img/spa.xcf
  31. 1367
      doc/doc-dpa/main.xml
  32. 152
      doc/doc-dpa/xsl/fo.xsl
  33. 9
      doc/doc-dpa/xsl/html-chunked.xsl
  34. 9
      doc/doc-dpa/xsl/html-onepage.xsl
  35. 9
      doc/doc-dpa/xsl/xhtml-chunked.xsl
  36. 9
      doc/doc-dpa/xsl/xhtml-onepage.xsl
  37. 124
      doc/globals/Makefile
  38. 220
      doc/globals/common-fo.xsl
  39. 36
      doc/globals/common-html-chunked.xsl
  40. 36
      doc/globals/common-html-onepage.xsl
  41. 36
      doc/globals/common-xhtml-chunked.xsl
  42. 36
      doc/globals/common-xhtml-onepage.xsl
  43. 16
      doc/globals/fonts/addfont.sh
  44. BIN
      doc/globals/fonts/cour.ttf
  45. 1
      doc/globals/fonts/cour.xml
  46. BIN
      doc/globals/fonts/courbd.ttf
  47. 1
      doc/globals/fonts/courbd.xml
  48. BIN
      doc/globals/fonts/courbi.ttf
  49. 1
      doc/globals/fonts/courbi.xml
  50. BIN
      doc/globals/fonts/couri.ttf
  51. 1
      doc/globals/fonts/couri.xml
  52. BIN
      doc/globals/fonts/georgia.ttf
  53. 1
      doc/globals/fonts/georgia.xml
  54. BIN
      doc/globals/fonts/georgiab.ttf
  55. 1
      doc/globals/fonts/georgiab.xml
  56. BIN
      doc/globals/fonts/georgiai.ttf
  57. 1
      doc/globals/fonts/georgiai.xml
  58. BIN
      doc/globals/fonts/georgiaz.ttf
  59. 1
      doc/globals/fonts/georgiaz.xml
  60. 149
      doc/globals/fop.xconf
  61. 1
      doc/template/Makefile
  62. 1
      doc/template/docbook
  63. 1
      doc/template/fop.xconf
  64. 35
      doc/template/main.xml
  65. 11
      doc/template/xsl/fo.xsl
  66. 9
      doc/template/xsl/html-chunked.xsl
  67. 9
      doc/template/xsl/html-onepage.xsl
  68. 9
      doc/template/xsl/xhtml-chunked.xsl
  69. 9
      doc/template/xsl/xhtml-onepage.xsl
  70. 9
      src/Java/DPA/README
  71. 220
      src/Java/DPA/src/dpa/RsaTest.java
  72. 233
      src/Java/DPA/src/dpa/RsaTest2.java
  73. 1
      src/Java/DPA/traces
  74. 10
      src/Mathematica/README
  75. 8422
      src/Mathematica/dpa-mb.nb
  76. 7026
      src/Mathematica/dpa.nb
  77. 67
      src/Matlab/CPA/cpa_compute_cpa.m
  78. 10
      src/Matlab/CPA/cpa_get_hamming_weigth.m
  79. 21
      src/Matlab/CPA/cpa_get_hamming_weigth_per_sbox.m
  80. 23
      src/Matlab/CPA/cpa_load_curves.m
  81. 16
      src/Matlab/DPA/dpa_des_block2hexstr.m
  82. 15
      src/Matlab/DPA/dpa_des_deckeychunk2block.m
  83. 160
      src/Matlab/DPA/dpa_des_display_mean.m
  84. 77
      src/Matlab/DPA/dpa_des_dpa.m
  85. 48
      src/Matlab/DPA/dpa_des_dpa_test.m
  86. 6
      src/Matlab/DPA/dpa_des_expand_key_chunk.m
  87. 25
      src/Matlab/DPA/dpa_des_get_power.m
  88. 14
      src/Matlab/DPA/dpa_des_hexstr2block.m
  89. 18
      src/Matlab/DPA/dpa_des_oracle.m
  90. 50
      src/Matlab/DPA/dpa_des_oracle_test.m
  91. 21
      src/Matlab/DPA/dpa_des_pencryption.m
  92. 14
      src/Matlab/DPA/dpa_des_power_model.m
  93. 8
      src/Matlab/DPA/dpa_des_power_simplest_model.m
  94. 4
      src/Matlab/DPA/dpa_des_power_simplest_model_criteria.m
  95. 78
      src/Matlab/DPA/dpa_des_reverse_ks.m
  96. 22
      src/Matlab/DPA/dpa_des_reverse_permutation.m
  97. 17
      src/Matlab/DPA/dpa_des_selection_function.m
  98. 27
      src/Matlab/DPA/dpa_des_spike.m
  99. 12
      src/Matlab/DataEncryptionStandard/des_block_interchange.m
  100. 17
      src/Matlab/DataEncryptionStandard/des_cipher_function.m

22
doc/Makefile

@ -0,0 +1,22 @@
SUBDIRS := $(wildcard doc-*)
help:
@echo "Usages: make <target>"
@echo " all : build all documentations"
@echo " new-doc : create a new documentation from a template"
@echo " clean : clean all documentations"
all: $(SUBDIRS)
$(SUBDIRS):
make -C $@ all
clean:
@for i in $(SUBDIRS); do make -C "$$i" clean || exit 1; done
new-doc: template
@echo "Enter the name of your documentation (no space, special chars, etc.): "
@echo -n "name> " ; read name ; echo "Creating doc-$$name..." ; cp -r template "doc-$$name"
.PHONY: $(SUBDIRS) new-doc all help clean

1
doc/doc-dpa-ensi/Makefile

@ -0,0 +1 @@
../globals/Makefile

1
doc/doc-dpa-ensi/docbook

@ -0,0 +1 @@
../globals/docbook

1
doc/doc-dpa-ensi/files

@ -0,0 +1 @@
../doc-dpa/files/

1
doc/doc-dpa-ensi/fop.xconf

@ -0,0 +1 @@
../globals/fop.xconf

1
doc/doc-dpa-ensi/img

@ -0,0 +1 @@
../doc-dpa/img/

1
doc/doc-dpa-ensi/main.xml

@ -0,0 +1 @@
../doc-dpa/main.xml

272
doc/doc-dpa-ensi/xsl/fo.xsl

@ -0,0 +1,272 @@
<?xml version='1.0'?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
<xsl:import href="../../globals/xsl-stylesheets/fo/docbook.xsl" />
<!-- Biblio -->
<xsl:param name="bibliography.numbered" select="1"/>
<!-- Custom titlepage for the ENSI -->
<xsl:template name="book.titlepage.recto">
<!-- ENSI -->
<fo:block-container absolute-position="absolute" top="-10mm" left="0mm">
<fo:block>
<fo:external-graphic
src="img/logos/ensi.png"
content-width="4cm"
content-type="content-type:image/png" />
</fo:block>
<fo:block font-family="serif" font-size="12pt">6, bd maréchal Juin</fo:block>
<fo:block font-family="serif" font-size="12pt" space-before="0pt">F-14050 Caen Cedex 4</fo:block>
<fo:block font-family="serif" font-size="14pt" space-before="5pt">Spécialité informatique</fo:block>
<fo:block font-family="serif" font-size="14pt" space-before="0pt">Option Monétique</fo:block>
<fo:block font-family="serif" font-size="14pt" space-before="0pt">3<fo:inline vertical-align="super" font-size="8pt">e</fo:inline> année</fo:block>
</fo:block-container>
<!-- ENSI vertical -->
<fo:block-container absolute-position="absolute" bottom="-10mm" left="-2mm" display-align="after">
<fo:block>
<fo:external-graphic
src="img/logos/ensi-vertical-long.png"
content-height="21.59cm"
content-type="content-type:image/png" />
</fo:block>
</fo:block-container>
<!-- Ingenico -->
<fo:block-container absolute-position="absolute" top="-10mm" right="0mm">
<fo:block text-align="right">
<fo:external-graphic
src="img/logos/ingenico.jpg"
content-width="6cm"
content-type="content-type:image/jpeg" />
</fo:block>
<fo:block text-align="right" font-family="serif" font-size="12pt">192, Avenue Charles de Gaulle</fo:block>
<fo:block text-align="right" font-family="serif" font-size="12pt">92200 Neuilly-Sur-Seine</fo:block>
<fo:block text-align="right" font-family="serif" font-size="12pt">http://www.ingenico.fr/</fo:block>
</fo:block-container>
<!-- Title -->
<fo:block-container absolute-position="absolute" top="6cm" bottom="2cm" left="20mm" right="0cm" display-align="center">
<fo:block text-align="center" font-family="serif" font-size="18pt" space-after="15mm">
<xsl:value-of select="bookinfo/subtitle" />
</fo:block>
<fo:block text-align="center" space-after="0mm"><fo:leader leader-length="5cm" leader-pattern="rule" rule-thickness="1pt"/></fo:block>
<fo:block text-align="center" font-family="serif" font-size="36pt" space-before="7.8mm" space-after="7.8mm">
<xsl:value-of select="bookinfo/title" />
</fo:block>
<fo:block text-align="center" space-before="0mm"><fo:leader leader-length="5cm" leader-pattern="rule" rule-thickness="1pt"/></fo:block>
<fo:block text-align="center" font-family="serif" font-size="14pt" space-before="20mm">
<xsl:apply-templates select="bookinfo/author[position()=1]" />
</fo:block>
<fo:block text-align="center" font-family="serif" font-size="14pt">
<xsl:apply-templates select="bookinfo/author[position()=2]" />
</fo:block>
</fo:block-container>
<!-- Suivi -->
<fo:block-container absolute-position="absolute" bottom="-10mm" left="20mm" display-align="after">
<fo:block font-family="serif" font-size="14pt">Suivi Ensicaen :</fo:block>
<fo:block font-family="serif" font-size="14pt">OTMANI Ayoub</fo:block>
<fo:block font-family="serif" font-size="14pt" space-before="14pt">Suivi Entreprise :</fo:block>
<fo:block font-family="serif" font-size="14pt">NACCACHE David</fo:block>
</fo:block-container>
<!-- Date -->
<fo:block-container absolute-position="absolute" bottom="-10mm" right="0mm" display-align="after">
<fo:block text-align="right" font-family="serif" font-size="14pt">1<fo:inline vertical-align="super" font-size="8pt">er</fo:inline> semestre 2006-2007</fo:block>
</fo:block-container>
</xsl:template>
<!-- User defined page layout -->
<xsl:template name="user.pagemasters">
<!-- custom setup for title page(s) -->
<fo:page-sequence-master master-name="custom-titlepage">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="blank"
blank-or-not-blank="blank"/>
<fo:conditional-page-master-reference master-reference="custom-titlepage-first"
page-position="first"/>
<fo:conditional-page-master-reference master-reference="titlepage-odd"
odd-or-even="odd"/>
<fo:conditional-page-master-reference
odd-or-even="even">
<xsl:attribute name="master-reference">
<xsl:choose>
<xsl:when test="$double.sided != 0">titlepage-even</xsl:when>
<xsl:otherwise>titlepage-odd</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</fo:conditional-page-master-reference>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
<!-- Custom first title page -->
<fo:simple-page-master master-name="custom-titlepage-first"
page-width="{$page.width}"
page-height="{$page.height}"
margin-top="20mm"
margin-bottom="20mm"
margin-left="20mm"
margin-right="20mm">
<fo:region-body margin-bottom="0mm"
margin-top="0mm"
column-count="1">
</fo:region-body>
</fo:simple-page-master>
</xsl:template>
<!-- Wrapper override -->
<xsl:template name="select.user.pagemaster">
<xsl:param name="element"/>
<xsl:param name="pageclass"/>
<xsl:param name="default-pagemaster"/>
<!-- Return my customized title page master name if for titlepage,
otherwise return the default -->
<xsl:choose>
<xsl:when test="$default-pagemaster = 'titlepage'">
<xsl:value-of select="'custom-titlepage'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$default-pagemaster"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Don't forget the quotes inside the double quotes -->
<xsl:param name="paper.type" select="'A4'" />
<xsl:param name="page.orientation" select="'portrait'" />
<!-- Print section numbers -->
<xsl:param name="section.autolabel" select="1" />
<xsl:param name="section.label.includes.component.label" select="1" />
<!--
<xsl:template match="*" mode="intralabel.punctuation">
<xsl:text>-</xsl:text>
</xsl:template>
-->
<!-- Customization of the TOC : indent by 10 pt -->
<xsl:param name="toc.indent.width" select="10" />
<!-- Do not indent the body -->
<xsl:param name="body.start.indent" select="0pt" />
<!-- The text body is 12pt large -->
<xsl:param name="body.font.master" select="12" />
<!-- Title are 'times new roman' -->
<xsl:param name="title.font.family" select="'serif'" />
<!-- Images path -->
<xsl:param name="img.src.path">img/</xsl:param>
<!-- No rule between the header and the body -->
<xsl:param name="header.rule" select="0"/>
<!-- No rule between the footer and the body -->
<xsl:param name="footer.rule" select="0"/>
<!-- No header -->
<xsl:template name="header.content" />
<!-- Standard numbering-->
<xsl:template name="page.number.format">1</xsl:template>
<!-- No point after the section numbering -->
<xsl:param name="autotoc.label.separator" select="' '" />
<!-- Set the default font for the text body -->
<!-- <xsl:param name="body.font.family" select="'Georgia'"/> -->
<!-- Custom separator between numbering and titles -->
<xsl:param name="local.l10n.xml" select="document('')" />
<l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">
<l:l10n language="fr">
<l:context name="title-numbered">
<l:template name="appendix" text="Annexe&#160;%n.&#160;%t"/>
<l:template name="chapter" text="%n&#160;&#160;%t"/>
<l:template name="sect1" text="%n&#160;&#160;%t"/>
<l:template name="sect2" text="%n&#160;&#160;%t"/>
<l:template name="sect3" text="%n&#160;&#160;%t"/>
<l:template name="sect4" text="%n&#160;&#160;%t"/>
<l:template name="sect5" text="%n&#160;&#160;%t"/>
<l:template name="section" text="%n&#160;&#160;%t"/>
</l:context>
</l:l10n>
</l:i18n>
<!-- Customization of the bibliography -->
<xsl:template match="title" mode="bibliodiv.titlepage.recto.auto.mode">
<fo:block xsl:use-attribute-sets="section.title.properties section.title.level1.properties">
<xsl:value-of select="." />
</fo:block>
</xsl:template>
<!-- Customization of the glossary -->
<xsl:template match="title" mode="glossdiv.titlepage.recto.auto.mode">
<fo:block xsl:use-attribute-sets="section.title.properties section.title.level1.properties">
<xsl:value-of select="." />
</fo:block>
</xsl:template>
<!-- Component's title (chapter, appendix, etc.) -->
<xsl:attribute-set name="component.title.properties">
<xsl:attribute name="font-size">22pt</xsl:attribute>
</xsl:attribute-set>
<!-- Section 1 title -->
<xsl:attribute-set name="section.title.level1.properties">
<xsl:attribute name="font-size">18pt</xsl:attribute>
</xsl:attribute-set>
<!-- Section 2 title -->
<xsl:attribute-set name="section.title.level2.properties">
<xsl:attribute name="font-size">16pt</xsl:attribute>
<xsl:attribute name="start-indent">1.27cm</xsl:attribute>
</xsl:attribute-set>
<!-- Section 3 title -->
<xsl:attribute-set name="section.title.level3.properties">
<xsl:attribute name="font-size">14pt</xsl:attribute>
<xsl:attribute name="start-indent">1.27cm</xsl:attribute>
</xsl:attribute-set>
<!-- Section 4 title -->
<xsl:attribute-set name="section.title.level4.properties">
<xsl:attribute name="font-size">12pt</xsl:attribute>
<xsl:attribute name="start-indent">1.27cm</xsl:attribute>
</xsl:attribute-set>
<!-- Custom title for the table of contents-->
<xsl:template name="table.of.contents.titlepage" priority="1">
<fo:block xsl:use-attribute-sets="component.title.properties"
font-weight="bold"
space-after="12pt">
<xsl:call-template name="gentext">
<xsl:with-param name="key" select="'TableofContents'"/>
</xsl:call-template>
</fo:block>
</xsl:template>
<!-- Custom title for the list of figures -->
<xsl:template name="list.of.figures.titlepage" priority="1">
<fo:block xsl:use-attribute-sets="component.title.properties"
font-weight="bold"
space-after="12pt">
<xsl:call-template name="gentext">
<xsl:with-param name="key" select="'ListofFigures'"/>
</xsl:call-template>
</fo:block>
</xsl:template>
</xsl:stylesheet>

1
doc/doc-dpa-ensi/xsl/html-chunked.xsl

@ -0,0 +1 @@
../../doc-dpa/xsl/html-chunked.xsl

1
doc/doc-dpa-ensi/xsl/html-onepage.xsl

@ -0,0 +1 @@
../../doc-dpa/xsl/html-onepage.xsl

1
doc/doc-dpa-ensi/xsl/xhtml-chunked.xsl

@ -0,0 +1 @@
../../doc-dpa/xsl/xhtml-chunked.xsl

1
doc/doc-dpa-ensi/xsl/xhtml-onepage.xsl

@ -0,0 +1 @@
../../doc-dpa/xsl/xhtml-onepage.xsl

1
doc/doc-dpa/Makefile

@ -0,0 +1 @@
../globals/Makefile

1
doc/doc-dpa/docbook

@ -0,0 +1 @@
../globals/docbook

1
doc/doc-dpa/fop.xconf

@ -0,0 +1 @@
../globals/fop.xconf

BIN
doc/doc-dpa/img/dpa1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

BIN
doc/doc-dpa/img/dpa2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
doc/doc-dpa/img/dpa3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
doc/doc-dpa/img/flowcert.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

1
doc/doc-dpa/img/gantt.png

@ -0,0 +1 @@
../../../ProjectManagement/gantt.png

BIN
doc/doc-dpa/img/leak.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
doc/doc-dpa/img/logos/ensi-vertical-long.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
doc/doc-dpa/img/logos/ensi-vertical.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
doc/doc-dpa/img/logos/ensi.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

BIN
doc/doc-dpa/img/logos/ingenico.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
doc/doc-dpa/img/organisation.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
doc/doc-dpa/img/precharged-bus.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
doc/doc-dpa/img/side-channels.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
doc/doc-dpa/img/spa.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

BIN
doc/doc-dpa/img/spa.xcf

Binary file not shown.

1367
doc/doc-dpa/main.xml

File diff suppressed because it is too large

152
doc/doc-dpa/xsl/fo.xsl

@ -0,0 +1,152 @@
<?xml version='1.0'?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
<xsl:import href="../../globals/common-fo.xsl" />
<!-- <xsl:include href="./titlepage.xsl" /> -->
<!-- Biblio -->
<xsl:param name="bibliography.numbered" select="1"/>
<!-- Draft mode
<xsl:attribute-set name="normal.para.spacing">
<xsl:attribute name="space-before.optimum">1em</xsl:attribute>
<xsl:attribute name="space-before.minimum">0.8em</xsl:attribute>
<xsl:attribute name="space-before.maximum">1.2em</xsl:attribute>
<xsl:attribute name="line-height">16pt</xsl:attribute>
</xsl:attribute-set> -->
<!-- Custom titlepage for the ENSI -->
<xsl:template name="book.titlepage.recto">
<!-- ENSI -->
<fo:block-container absolute-position="absolute" top="0mm" left="0mm">
<fo:block>
<fo:external-graphic
src="img/logos/ensi.png"
content-width="4cm"
content-type="content-type:image/png" />
</fo:block>
<fo:block font-family="serif" font-size="12pt">6, bd maréchal Juin</fo:block>
<fo:block font-family="serif" font-size="12pt" space-before="0pt">F-14050 Caen Cedex 4</fo:block>
<fo:block font-family="serif" font-size="14pt" space-before="5pt">Spécialité informatique</fo:block>
<fo:block font-family="serif" font-size="14pt" space-before="0pt">Option Monétique</fo:block>
<fo:block font-family="serif" font-size="14pt" space-before="0pt">3<fo:inline vertical-align="super" font-size="8pt">e</fo:inline> année</fo:block>
</fo:block-container>
<!-- ENSI vertical -->
<fo:block-container absolute-position="absolute" bottom="0mm" left="-2mm" display-align="after">
<fo:block>
<fo:external-graphic
src="img/logos/ensi-vertical-long.png"
content-height="21.59cm"
content-type="content-type:image/png" />
</fo:block>
</fo:block-container>
<!-- Ingenico -->
<fo:block-container absolute-position="absolute" top="0mm" right="0mm">
<fo:block text-align="right">
<fo:external-graphic
src="img/logos/ingenico.jpg"
content-width="6cm"
content-type="content-type:image/jpeg" />
</fo:block>
<fo:block text-align="right" font-family="serif" font-size="12pt">192, Avenue Charles de Gaulle</fo:block>
<fo:block text-align="right" font-family="serif" font-size="12pt">92200 Neuilly-Sur-Seine</fo:block>
<fo:block text-align="right" font-family="serif" font-size="12pt">http://www.ingenico.fr/</fo:block>
</fo:block-container>
<!-- Title -->
<fo:block-container absolute-position="absolute" top="6cm" bottom="2cm" left="20mm" right="0cm" display-align="center">
<fo:block text-align="center" font-family="serif" font-size="18pt" space-after="15mm">
<xsl:value-of select="bookinfo/subtitle" />
</fo:block>
<fo:block text-align="center" space-after="0mm"><fo:leader leader-length="5cm" leader-pattern="rule" rule-thickness="1pt"/></fo:block>
<fo:block text-align="center" font-family="serif" font-size="36pt" space-before="7.8mm" space-after="7.8mm">
<xsl:value-of select="bookinfo/title" />
</fo:block>
<fo:block text-align="center" space-before="0mm"><fo:leader leader-length="5cm" leader-pattern="rule" rule-thickness="1pt"/></fo:block>
<fo:block text-align="center" font-family="serif" font-size="14pt" space-before="20mm">
<xsl:apply-templates select="bookinfo/author[position()=1]" />
</fo:block>
<fo:block text-align="center" font-family="serif" font-size="14pt">
<xsl:apply-templates select="bookinfo/author[position()=2]" />
</fo:block>
</fo:block-container>
<!-- Suivi -->
<fo:block-container absolute-position="absolute" bottom="0mm" left="20mm" display-align="after">
<fo:block font-family="serif" font-size="14pt">Suivi Ensicaen :</fo:block>
<fo:block font-family="serif" font-size="14pt">OTMANI Ayoub</fo:block>
<fo:block font-family="serif" font-size="14pt" space-before="14pt">Suivi Entreprise :</fo:block>
<fo:block font-family="serif" font-size="14pt">NACCACHE David</fo:block>
</fo:block-container>
<!-- Date -->
<fo:block-container absolute-position="absolute" bottom="0mm" right="0mm" display-align="after">
<fo:block text-align="right" font-family="serif" font-size="14pt">1<fo:inline vertical-align="super" font-size="8pt">er</fo:inline> semestre 2006-2007</fo:block>
</fo:block-container>
</xsl:template>
<!-- User defined page layout -->
<xsl:template name="user.pagemasters">
<!-- custom setup for title page(s) -->
<fo:page-sequence-master master-name="custom-titlepage">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="blank"
blank-or-not-blank="blank"/>
<fo:conditional-page-master-reference master-reference="custom-titlepage-first"
page-position="first"/>
<fo:conditional-page-master-reference master-reference="titlepage-odd"
odd-or-even="odd"/>
<fo:conditional-page-master-reference
odd-or-even="even">
<xsl:attribute name="master-reference">
<xsl:choose>
<xsl:when test="$double.sided != 0">titlepage-even</xsl:when>
<xsl:otherwise>titlepage-odd</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</fo:conditional-page-master-reference>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
<!-- Custom first title page -->
<fo:simple-page-master master-name="custom-titlepage-first"
page-width="{$page.width}"
page-height="{$page.height}"
margin-top="10mm"
margin-bottom="10mm"
margin-left="20mm"
margin-right="20mm">
<fo:region-body margin-bottom="0mm"
margin-top="0mm"
column-count="1">
</fo:region-body>
</fo:simple-page-master>
</xsl:template>
<!-- Wrapper override -->
<xsl:template name="select.user.pagemaster">
<xsl:param name="element"/>
<xsl:param name="pageclass"/>
<xsl:param name="default-pagemaster"/>
<!-- Return my customized title page master name if for titlepage,
otherwise return the default -->
<xsl:choose>
<xsl:when test="$default-pagemaster = 'titlepage'">
<xsl:value-of select="'custom-titlepage'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$default-pagemaster"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

9
doc/doc-dpa/xsl/html-chunked.xsl

@ -0,0 +1,9 @@
<?xml version='1.0'?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
<xsl:import href="../../globals/common-html-chunked.xsl" />
</xsl:stylesheet>

9
doc/doc-dpa/xsl/html-onepage.xsl

@ -0,0 +1,9 @@
<?xml version='1.0'?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
<xsl:import href="../../globals/common-html-onepage.xsl" />
</xsl:stylesheet>

9
doc/doc-dpa/xsl/xhtml-chunked.xsl

@ -0,0 +1,9 @@
<?xml version='1.0'?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
<xsl:import href="../../globals/common-xhtml-chunked.xsl" />
</xsl:stylesheet>

9
doc/doc-dpa/xsl/xhtml-onepage.xsl

@ -0,0 +1,9 @@
<?xml version='1.0'?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
<xsl:import href="../../globals/common-xhtml-onepage.xsl" />
</xsl:stylesheet>

124
doc/globals/Makefile

@ -0,0 +1,124 @@
# Environment variables
export PATH := $(HOME)/bin/fop:$(PATH)
export CLASSPATH := xsl/xsl-stylesheets/extensions/xalan25.jar
# Do you need a proxy ?
#export FOP_OPTS := -Dhttp.proxyHost=193.100.252.20 -Dhttp.proxyPort=8080
# Or any setting
export FOP_OPTS := -Xmx1G -Djava.awt.headless=true
# Target filenames
PDF_FILE := book.pdf
RTF_FILE := book.rtf
TXT_FILE := book.txt
PS_FILE := book.ps
XHTML_DIR := book-xhtml
XHTML1_DIR := onepage-xhtml
HTML_DIR := book-html
HTML1_DIR := onepage-html
XHTML_ARCH := book-xhtml.tar.bz2
HTML_ARCH := book-html.tar.bz2
XHTML1_ARCH := onepage-xhtml.tar.bz2
HTML1_ARCH := onepage-html.tar.bz2
VALIDITY_FILE := validity
# Source filenames
XSL_FO_FILE := xsl/fo.xsl
XSL_XHTML_FILE := xsl/xhtml-chunked.xsl
XSL_HTML_FILE := xsl/html-chunked.xsl
XSL_XHTML1_FILE := xsl/xhtml-onepage.xsl
XSL_HTML1_FILE := xsl/html-onepage.xsl
DB_FILE := main.xml
# Titlepage customization
TP_SPEC_FILE := xsl/titlepage.spec.xml
TP_XSL_FILE := xsl/titlepage.xsl
TP_TEMPLATE_FILE := ../globals/xsl-stylesheets/template/titlepage.xsl
# Do you have a custom titlepage ?
TP_XSL_REAL := $(shell if test -f $(TP_SPEC_FILE); then echo $(TP_XSL_FILE); fi)
# FOP configuration
FOP := fop
FOP_CONF := fop.xconf
# XSLT configuration
XSLTPROC := xsltproc
# Validity check
VALIDATOR := xmllint --noout --valid
# Extract external entities
XML_FILES := $(wildcard include/*.xml)
DEPENDENCIES := $(TP_XSL_REAL) $(VALIDITY_FILE)
# Default target
all: $(PDF_FILE) $(RTF_FILE) $(TXT_FILE) $(PS_FILE) $(XHTML_ARCH) $(HTML_ARCH) $(XHTML1_ARCH) $(HTML1_ARCH)
$(VALIDITY_FILE): $(DB_FILE) $(XML_FILES)
$(VALIDATOR) $<
touch $(VALIDITY_FILE)
$(PDF_FILE): $(DB_FILE) $(XSL_FO_FILE) $(DEPENDENCIES)
$(FOP) -c $(FOP_CONF) -xsl $(XSL_FO_FILE) -xml $< -pdf $@
$(RTF_FILE): $(DB_FILE) $(XSL_FO_FILE) $(DEPENDENCIES)
$(FOP) -c $(FOP_CONF) -xsl $(XSL_FO_FILE) -xml $< -rtf $@
$(TXT_FILE): $(DB_FILE) $(XSL_FO_FILE) $(DEPENDENCIES)
$(FOP) -c $(FOP_CONF) -xsl $(XSL_FO_FILE) -xml $< -txt $@
$(PS_FILE): $(DB_FILE) $(XSL_FO_FILE) $(DEPENDENCIES)
$(FOP) -c $(FOP_CONF) -xsl $(XSL_FO_FILE) -xml $< -ps $@
$(XHTML_DIR): $(DB_FILE) $(XSL_XHTML_FILE) $(DEPENDENCIES)
if [ ! -e $(XHTML_DIR) ]; then mkdir $(XHTML_DIR); ln -s ../img $(XHTML_DIR)/img; \
ln -s ../../globals/xsl-stylesheets/images $(XHTML_DIR)/std-img; fi
$(XSLTPROC) $(XSL_XHTML_FILE) $<
touch $(XHTML_DIR)
$(HTML_DIR): $(DB_FILE) $(XSL_HTML_FILE) $(DEPENDENCIES)
if [ ! -e $(HTML_DIR) ]; then mkdir $(HTML_DIR); ln -s ../img $(HTML_DIR)/img; \
ln -s ../../globals/xsl-stylesheets/images $(HTML_DIR)/std-img; fi
$(XSLTPROC) $(XSL_HTML_FILE) $<
touch $(HTML_DIR)
$(XHTML1_DIR): $(DB_FILE) $(XSL_XHTML1_FILE) $(DEPENDENCIES)
if [ ! -e $(XHTML_DIR) ]; then mkdir $(XHTML1_DIR); ln -s ../img $(XHTML1_DIR)/img; \
ln -s ../../globals/xsl-stylesheets/images $(XHTML1_DIR)/std-img; fi
$(XSLTPROC) -output $@/index.xhtml $(XSL_XHTML1_FILE) $<
touch $(XHTML1_DIR)
$(HTML1_DIR): $(DB_FILE) $(XSL_HTML1_FILE) $(DEPENDENCIES)
if [ ! -e $(HTML1_DIR) ]; then mkdir $(HTML1_DIR); ln -s ../img $(HTML1_DIR)/img; \
ln -s ../../globals/xsl-stylesheets/images $(HTML1_DIR)/std-img; fi
$(XSLTPROC) -output $@/index.html $(XSL_HTML1_FILE) $<
touch $(HTML1_DIR)
$(HTML_ARCH): $(HTML_DIR)
tar -jcv -h --exclude '.svn' --exclude '*.svg' -f $@ $<
$(XHTML_ARCH): $(XHTML_DIR)
tar -jcv -h --exclude '.svn' --exclude '*.svg' -f $@ $<
$(HTML1_ARCH): $(HTML1_DIR)
tar -jcv -h --exclude '.svn' --exclude '*.svg' -f $@ $<
$(XHTML1_ARCH): $(XHTML1_DIR)
tar -jcv -h --exclude '.svn' --exclude '*.svg' -f $@ $<
$(TP_XSL_FILE): $(TP_SPEC_FILE)
$(XSLTPROC) -output $@ $(TP_TEMPLATE_FILE) $<
clean:
rm -f $(PDF_FILE) $(TP_XSL_FILE) $(VALIDITY_FILE) $(HTML_ARCH) $(XHTML_ARCH) $(RTF_FILE) $(TXT_FILE) $(PS_FILE)
rm -rf $(XHTML_DIR) $(HTML_DIR) $(HTML1_DIR) $(XHTML1_DIR)
test:
@echo '$(XML_FILES)'
.PHONY: all clean test

220
doc/globals/common-fo.xsl

@ -0,0 +1,220 @@
<?xml version='1.0'?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
<xsl:import href="xsl-stylesheets/fo/docbook.xsl" />
<!-- Don't forget the quotes inside the double quotes -->
<xsl:param name="paper.type" select="'A4'" />
<xsl:param name="page.orientation" select="'portrait'" />
<!-- FOP extension, doesn't work !
<xsl:param name="fop.extensions" select="1" /> -->
<!-- Draft mode, not supported by FOP
<xsl:param name="draft.mode" select="maybe" /> -->
<!-- Print section numbers -->
<xsl:param name="section.autolabel" select="1" />
<!-- Display admonition icons (warning, note, tip, etc.) -->
<xsl:param name="admon.graphics" select="1" />
<xsl:param name="admon.graphics.extension" select="'.svg'" />
<xsl:param name="admon.graphics.path">../globals/xsl-stylesheets/images/</xsl:param>
<xsl:attribute-set name="graphical.admonition.properties">
<xsl:attribute name="space-before.optimum">1em</xsl:attribute>
<xsl:attribute name="space-before.minimum">0.8em</xsl:attribute>
<xsl:attribute name="space-before.maximum">1.2em</xsl:attribute>
<xsl:attribute name="space-after.optimum">1em</xsl:attribute>
<xsl:attribute name="space-after.minimum">0.8em</xsl:attribute>
<xsl:attribute name="space-after.maximum">1.2em</xsl:attribute>
<xsl:attribute name="border-style">dashed</xsl:attribute>
<xsl:attribute name="border-width">.5pt</xsl:attribute>
<xsl:attribute name="border-color">#555555</xsl:attribute>
<xsl:attribute name="background-color">#EEEEEE</xsl:attribute>
<xsl:attribute name="padding">5pt</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="admonition.properties">
</xsl:attribute-set>
<xsl:attribute-set name="admonition.title.properties">
<xsl:attribute name="font-family">sans-serif</xsl:attribute>
</xsl:attribute-set>
<!-- Callout configuration -->
<xsl:param name="callout.graphics" select="0" />
<xsl:param name="callout.unicode" select="1" />
<!-- Disable text label in admonitions -->
<!-- <xsl:param name="admon.textlabel" select="0" /> -->
<!-- Customization of the TOC : indent by 15 pt -->
<xsl:param name="toc.indent.width" select="15" />
<!-- Images path -->
<xsl:param name="img.src.path">img/</xsl:param>
<!-- Set the default font for the text body -->
<xsl:param name="body.font.family" select="'Georgia'"/>
<!-- Customize the font used for programlisting -->
<xsl:attribute-set name="monospace.properties">
<!-- Reduce the size of the monospace font -->
<xsl:attribute name="font-size">
<xsl:text>90%</xsl:text>
</xsl:attribute>
<!-- Light gray background -->
<xsl:attribute name="background-color">#EEEEEE</xsl:attribute>
<!-- Change the font to "Courier New" -->
<!-- <xsl:attribute name="font-family">CourierNew</xsl:attribute> -->
</xsl:attribute-set>
<!-- Template overload -->
<xsl:template name="inline.monoseq">
<xsl:param name="content">
<xsl:apply-templates/>
</xsl:param>
<fo:inline xsl:use-attribute-sets="monospace.properties">
<xsl:attribute name="background-color">transparent</xsl:attribute>
<xsl:if test="@dir">
<xsl:attribute name="direction">
<xsl:choose>
<xsl:when test="@dir = 'ltr' or @dir = 'lro'">ltr</xsl:when>
<xsl:otherwise>rtl</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:if>
<xsl:copy-of select="$content"/>
</fo:inline>
</xsl:template>
<!-- TOC template -->
<xsl:template name="toc.line">
<xsl:variable name="id">
<xsl:call-template name="object.id"/>
</xsl:variable>
<xsl:variable name="label">
<xsl:apply-templates select="." mode="label.markup"/>
</xsl:variable>
<fo:block text-align-last="justify"
text-align="start"
end-indent="{$toc.indent.width}pt"
last-line-end-indent="-{$toc.indent.width}pt">
<!-- Adds space before main elements -->
<xsl:choose>
<xsl:when test="parent::book">
<xsl:attribute name="space-before">3pt</xsl:attribute>
<xsl:attribute name="space-after">1pt</xsl:attribute>
</xsl:when>
</xsl:choose>
<fo:inline keep-with-next.within-line="always">
<!-- Main elements in bold -->
<xsl:choose>
<xsl:when test="parent::book">
<xsl:attribute name="font-weight">bold</xsl:attribute>
</xsl:when>
</xsl:choose>
<fo:basic-link internal-destination="{$id}">
<xsl:if test="$label != ''">
<xsl:copy-of select="$label"/>
<xsl:value-of select="$autotoc.label.separator"/>
</xsl:if>
<xsl:apply-templates select="." mode="titleabbrev.markup"/>
</fo:basic-link>
</fo:inline>
<fo:inline keep-together.within-line="always">
<xsl:text> </xsl:text>
<!-- Main elements do not have leaders (dots) -->
<xsl:choose>
<xsl:when test="parent::book">
<fo:leader leader-pattern="space"
leader-pattern-width="3pt"
leader-alignment="reference-area"
keep-with-next.within-line="always"/>
</xsl:when>
<xsl:otherwise>
<fo:leader leader-pattern="dots"
leader-pattern-width="3pt"
leader-alignment="reference-area"
keep-with-next.within-line="always"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text> </xsl:text>
<fo:basic-link internal-destination="{$id}">
<fo:page-number-citation ref-id="{$id}"/>
</fo:basic-link>
</fo:inline>
</fo:block>
</xsl:template>
<!-- Customization of the bibliography -->
<xsl:template match="title" mode="bibliodiv.titlepage.recto.auto.mode">
<fo:block xsl:use-attribute-sets="section.title.properties section.title.level1.properties">
<xsl:value-of select="." />
</fo:block>
</xsl:template>
<!-- Customization of the glossary -->
<xsl:template match="title" mode="glossdiv.titlepage.recto.auto.mode">
<fo:block xsl:use-attribute-sets="section.title.properties section.title.level1.properties">
<xsl:value-of select="." />
</fo:block>
</xsl:template>
<!-- Component's title (chapter, appendix, etc.) -->
<xsl:attribute-set name="component.title.properties">
<xsl:attribute name="font-size">
<xsl:value-of select="$body.font.master * 2"/>
<xsl:text>pt</xsl:text>
</xsl:attribute>
</xsl:attribute-set>
<!-- Section 1 title -->
<xsl:attribute-set name="section.title.level1.properties">
<xsl:attribute name="font-size">
<xsl:value-of select="$body.font.master * 1.75"/>
<xsl:text>pt</xsl:text>
</xsl:attribute>
<!--
<xsl:attribute name="border-bottom">0.5pt solid black</xsl:attribute>
<xsl:attribute name="margin-right">4cm</xsl:attribute>
-->
</xsl:attribute-set>
<!-- Section 2 title -->
<xsl:attribute-set name="section.title.level2.properties">
<xsl:attribute name="font-size">
<xsl:value-of select="$body.font.master * 1.5"/>
<xsl:text>pt</xsl:text>
</xsl:attribute>
</xsl:attribute-set>
<!-- Section 3 title -->
<xsl:attribute-set name="section.title.level3.properties">
<xsl:attribute name="font-size">
<xsl:value-of select="$body.font.master * 1.25"/>
<xsl:text>pt</xsl:text>
</xsl:attribute>
</xsl:attribute-set>
<!-- Section 4 title -->
<xsl:attribute-set name="section.title.level4.properties">
<xsl:attribute name="font-size">
<xsl:value-of select="$body.font.master * 1.1"/>
<xsl:text>pt</xsl:text>
</xsl:attribute>
</xsl:attribute-set>
</xsl:stylesheet>

36
doc/globals/common-html-chunked.xsl

@ -0,0 +1,36 @@
<?xml version='1.0'?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
<xsl:import href="xsl-stylesheets/html/chunk.xsl" />
<!-- <xsl:include href="./titlepage.xsl" /> -->
<!-- Don't forget the quotes inside the double quotes -->
<xsl:param name="base.dir" select="'./book-html/'" />
<!-- Print section numbers -->
<xsl:param name="section.autolabel" select="1" />
<!-- No image scaling -->
<xsl:param name="ignore.image.scaling" select="1" />
<!-- Display admonition icons (warning, note, tip, etc.) -->
<xsl:param name="admon.graphics" select="1" />
<xsl:param name="admon.graphics.extension" select="'.png'" />
<xsl:param name="admon.graphics.path">std-img/</xsl:param>
<!-- Disable text label in admonitions -->
<!-- <xsl:param name="admon.textlabel" select="0" /> -->
<!-- Callout configuration -->
<xsl:param name="callout.graphics" select="1" />
<xsl:param name="callout.graphics.extension" select="'.gif'" />
<xsl:param name="callout.graphics.path">std-img/callouts/</xsl:param>
<!-- Images path -->
<xsl:param name="img.src.path">img/</xsl:param>
</xsl:stylesheet>

36
doc/globals/common-html-onepage.xsl

@ -0,0 +1,36 @@
<?xml version='1.0'?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
<xsl:import href="xsl-stylesheets/html/docbook.xsl" />
<!-- <xsl:include href="./titlepage.xsl" /> -->
<!-- Don't forget the quotes inside the double quotes -->
<xsl:param name="base.dir" select="'./onepage-html/'" />
<!-- Print section numbers -->
<xsl:param name="section.autolabel" select="1" />
<!-- No image scaling -->
<xsl:param name="ignore.image.scaling" select="1" />
<!-- Display admonition icons (warning, note, tip, etc.) -->
<xsl:param name="admon.graphics" select="1" />
<xsl:param name="admon.graphics.extension" select="'.png'" />
<xsl:param name="admon.graphics.path">std-img/</xsl:param>
<!-- Disable text label in admonitions -->
<!-- <xsl:param name="admon.textlabel" select="0" /> -->
<!-- Callout configuration -->
<xsl:param name="callout.graphics" select="1" />
<xsl:param name="callout.graphics.extension" select="'.gif'" />
<xsl:param name="callout.graphics.path">std-img/callouts/</xsl:param>
<!-- Images path -->
<xsl:param name="img.src.path">img/</xsl:param>
</xsl:stylesheet>

36
doc/globals/common-xhtml-chunked.xsl

@ -0,0 +1,36 @@
<?xml version='1.0'?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
<xsl:import href="xsl-stylesheets/xhtml/chunk.xsl" />
<!-- <xsl:include href="./titlepage.xsl" /> -->
<!-- Don't forget the quotes inside the double quotes -->
<xsl:param name="base.dir" select="'./book-xhtml/'" />
<!-- Print section numbers -->
<xsl:param name="section.autolabel" select="1" />
<!-- No image scaling -->
<xsl:param name="ignore.image.scaling" select="1" />
<!-- Display admonition icons (warning, note, tip, etc.) -->
<xsl:param name="admon.graphics" select="1" />
<xsl:param name="admon.graphics.extension" select="'.png'" />
<xsl:param name="admon.graphics.path">std-img/</xsl:param>
<!-- Disable text label in admonitions -->
<!-- <xsl:param name="admon.textlabel" select="0" /> -->
<!-- Callout configuration -->
<xsl:param name="callout.graphics" select="1" />
<xsl:param name="callout.graphics.extension" select="'.gif'" />
<xsl:param name="callout.graphics.path">std-img/callouts/</xsl:param>
<!-- Images path -->
<xsl:param name="img.src.path">img/</xsl:param>
</xsl:stylesheet>

36
doc/globals/common-xhtml-onepage.xsl

@ -0,0 +1,36 @@
<?xml version='1.0'?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
<xsl:import href="xsl-stylesheets/xhtml/docbook.xsl" />
<!-- <xsl:include href="./titlepage.xsl" /> -->
<!-- Don't forget the quotes inside the double quotes -->
<xsl:param name="base.dir" select="'./onepage-xhtml/'" />
<!-- Print section numbers -->
<xsl:param name="section.autolabel" select="1" />
<!-- No image scaling -->
<xsl:param name="ignore.image.scaling" select="1" />
<!-- Display admonition icons (warning, note, tip, etc.) -->
<xsl:param name="admon.graphics" select="1" />
<xsl:param name="admon.graphics.extension" select="'.png'" />
<xsl:param name="admon.graphics.path">std-img/</xsl:param>
<!-- Disable text label in admonitions -->
<!-- <xsl:param name="admon.textlabel" select="0" /> -->
<!-- Callout configuration -->
<xsl:param name="callout.graphics" select="1" />
<xsl:param name="callout.graphics.extension" select="'.gif'" />
<xsl:param name="callout.graphics.path">std-img/callouts/</xsl:param>
<!-- Images path -->
<xsl:param name="img.src.path">img/</xsl:param>
</xsl:stylesheet>

16
doc/globals/fonts/addfont.sh

@ -0,0 +1,16 @@
#!/bin/sh
FOP_PREFIX="$HOME/bin/fop"
CLASSPATH="$FOP_PREFIX/build/fop.jar:$FOP_PREFIX/lib/xercesImpl.jar:$FOP_PREFIX/lib/xalan.jar"
CLASSPATH="$CLASSPATH:$FOP_PREFIX/lib/avalon-framework.jar:$FOP_PREFIX/lib/xml-apis.jar"
CLASSPATH="$CLASSPATH:$FOP_PREFIX/lib/commons-logging-1.0.4.jar:$FOP_PREFIX/lib/commons-io-1.1.jar"
CLASS="org.apache.fop.fonts.apps.TTFReader"
ENC="ansi"
if [ $# -ne 1 ]; then
echo "Usage: $0 <ttf file>"
exit 1
fi
java -cp "$CLASSPATH" "$CLASS" -enc "$ENC" "$1" "$(echo "$1" |sed 's/\.[Tt][Tt][Ff]//').xml"

BIN
doc/globals/fonts/cour.ttf

Binary file not shown.

1
doc/globals/fonts/cour.xml

File diff suppressed because one or more lines are too long

BIN
doc/globals/fonts/courbd.ttf

Binary file not shown.

1
doc/globals/fonts/courbd.xml

File diff suppressed because one or more lines are too long

BIN
doc/globals/fonts/courbi.ttf

Binary file not shown.

1
doc/globals/fonts/courbi.xml

File diff suppressed because one or more lines are too long

BIN
doc/globals/fonts/couri.ttf

Binary file not shown.

1
doc/globals/fonts/couri.xml

File diff suppressed because one or more lines are too long

BIN
doc/globals/fonts/georgia.ttf

Binary file not shown.

1
doc/globals/fonts/georgia.xml

File diff suppressed because one or more lines are too long

BIN
doc/globals/fonts/georgiab.ttf

Binary file not shown.

1
doc/globals/fonts/georgiab.xml

File diff suppressed because one or more lines are too long

BIN
doc/globals/fonts/georgiai.ttf

Binary file not shown.

1
doc/globals/fonts/georgiai.xml

File diff suppressed because one or more lines are too long

BIN
doc/globals/fonts/georgiaz.ttf

Binary file not shown.

1
doc/globals/fonts/georgiaz.xml

File diff suppressed because one or more lines are too long

149
doc/globals/fop.xconf

@ -0,0 +1,149 @@
<?xml version="1.0"?>
<!-- NOTE: This is the version of the configuration -->
<fop version="1.0">
<!-- Base URL for resolving relative URLs -->
<base>.</base>
<!-- Font Base URL -->
<font-base>../globals/fonts</font-base>
<!-- Source resolution in dpi (dots/pixels per inch) for determining the size of pixels in SVG and bitmap images, default: 72dpi -->
<source-resolution>300</source-resolution>
<!-- Target resolution in dpi (dots/pixels per inch) for specifying the target resolution for generated bitmaps, default: 72dpi -->
<target-resolution>300</target-resolution>
<!-- Default page-height and page-width, in case
value is specified as auto -->
<!-- <default-page-settings height="297mm" width="210mm"/> -->
<!-- Information for specific renderers -->
<!-- Uses renderer mime type for renderers -->
<renderers>
<renderer mime="application/pdf">
<filterList>
<!-- provides compression using zlib flate (default is on) -->
<value>flate</value>
<!-- encodes binary data into printable ascii characters (default off)
This provides about a 4:5 expansion of data size -->
<!-- <value>ascii-85</value> -->
<!-- encodes binary data with hex representation (default off)
This filter is not recommended as it doubles the data size -->
<!-- <value>ascii-hex</value> -->
</filterList>
<fonts>
<!-- embedded fonts -->
<!--
This information must exactly match the font specified
in the fo file. Otherwise it will use a default font.
For example,
<fo:inline font-family="Arial" font-weight="bold" font-style="normal">
Arial-normal-normal font
</fo:inline>
for the font triplet specified by:
<font-triplet name="Arial" style="normal" weight="bold"/>
If you do not want to embed the font in the pdf document
then do not include the "embed-url" attribute.
The font will be needed where the document is viewed
for it to be displayed properly.
possible styles: normal | italic | oblique | backslant
possible weights: normal | bold | 100 | 200 | 300 | 400
| 500 | 600 | 700 | 800 | 900
(normal = 400, bold = 700)
-->
<!--
<font metrics-url="arial.xml" kerning="yes" embed-url="arial.ttf">
<font-triplet name="Arial" style="normal" weight="normal"/>
<font-triplet name="ArialMT" style="normal" weight="normal"/>
</font>
<font metrics-url="arialb.xml" kerning="yes" embed-url="arialb.ttf">
<font-triplet name="Arial" style="normal" weight="bold"/>
<font-triplet name="ArialMT" style="normal" weight="bold"/>
</font>
-->
<!-- <font metrics-url="cour.xml" kerning="yes" embed-url="cour.ttf">
<font-triplet name="CourierNew" style="normal" weight="normal"/>
</font>
<font metrics-url="courbd.xml" kerning="yes" embed-url="courbd.ttf">
<font-triplet name="CourierNew" style="normal" weight="bold"/>
</font>
<font metrics-url="courbi.xml" kerning="yes" embed-url="courbi.ttf">
<font-triplet name="CourierNew" style="italic" weight="bold"/>
</font>
<font metrics-url="couri.xml" kerning="yes" embed-url="couri.ttf">
<font-triplet name="CourierNew" style="italic" weight="normal"/>
</font> -->
<font metrics-url="georgia.xml" kerning="yes" embed-url="georgia.ttf">
<font-triplet name="Georgia" style="normal" weight="normal"/>
</font>
<font metrics-url="georgiab.xml" kerning="yes" embed-url="georgiab.ttf">
<font-triplet name="Georgia" style="normal" weight="bold"/>
</font>
<font metrics-url="georgiaz.xml" kerning="yes" embed-url="georgiaz.ttf">
<font-triplet name="Georgia" style="italic" weight="bold"/>
</font>
<font metrics-url="georgiai.xml" kerning="yes" embed-url="georgiai.ttf">
<font-triplet name="Georgia" style="italic" weight="normal"/>
</font>
</fonts>
<!-- This option lets you specify additional options on an XML handler -->
<!--xml-handler namespace="http://www.w3.org/2000/svg">
<stroke-text>false</stroke-text>
</xml-handler-->
</renderer>
<renderer mime="application/postscript">
<!-- This option forces the PS renderer to rotate landscape pages -->
<!--auto-rotate-landscape>true</auto-rotate-landscape-->
<!-- This option lets you specify additional options on an XML handler -->
<!--xml-handler namespace="http://www.w3.org/2000/svg">
<stroke-text>false</stroke-text>
</xml-handler-->
</renderer>
<renderer mime="application/vnd.hp-PCL">
</renderer>
<!-- MIF does not have a renderer
<renderer mime="application/vnd.mif">
</renderer>
-->
<renderer mime="image/svg+xml">
<format type="paginated"/>
<link value="true"/>
<strokeText value="false"/>
</renderer>
<renderer mime="application/awt">
</renderer>
<renderer mime="text/xml">
</renderer>
<!-- RTF does not have a renderer
<renderer mime="text/rtf">
</renderer>
-->
<renderer mime="text/plain">
<pageSize columns="80"/>
</renderer>
</renderers>
</fop>

1
doc/template/Makefile

@ -0,0 +1 @@
../globals/Makefile

1
doc/template/docbook

@ -0,0 +1 @@
../globals/docbook

1
doc/template/fop.xconf

@ -0,0 +1 @@
../globals/fop.xconf

35
doc/template/main.xml

@ -0,0 +1,35 @@
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<book>
<!-- Metadata -->
<bookinfo>
<title>Title</title>
<author>
<firstname>John</firstname><surname>SMITH</surname>
<affiliation>
<orgname>ACME corp.</orgname>
<orgdiv>IT dept.</orgdiv>
</affiliation>
<email>john@acme.com</email>
</author>
<copyright>
<year>2000</year>
<holder>ACME corp.</holder>
</copyright>
</bookinfo>
<preface>
<title>Foreword</title>
<para></para>
</preface>
<chapter>
<title>My First Document with Docbook</title>
<sect1>
<title>What is docbook ?</title>
<para>A paragraph</para>
</sect1>
</chapter>
</book>

11
doc/template/xsl/fo.xsl

@ -0,0 +1,11 @@
<?xml version='1.0'?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
<xsl:import href="../../globals/common-fo.xsl" />
<!-- <xsl:include href="./titlepage.xsl" /> -->
</xsl:stylesheet>

9
doc/template/xsl/html-chunked.xsl

@ -0,0 +1,9 @@
<?xml version='1.0'?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
<xsl:import href="../../globals/common-html-chunked.xsl" />
</xsl:stylesheet>

9
doc/template/xsl/html-onepage.xsl

@ -0,0 +1,9 @@
<?xml version='1.0'?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
<xsl:import href="../../globals/common-html-onepage.xsl" />
</xsl:stylesheet>

9
doc/template/xsl/xhtml-chunked.xsl

@ -0,0 +1,9 @@
<?xml version='1.0'?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
<xsl:import href="../../globals/common-xhtml-chunked.xsl" />
</xsl:stylesheet>

9
doc/template/xsl/xhtml-onepage.xsl

@ -0,0 +1,9 @@
<?xml version='1.0'?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
<xsl:import href="../../globals/common-xhtml-onepage.xsl" />
</xsl:stylesheet>

9
src/Java/DPA/README

@ -0,0 +1,9 @@
Ce dossier contient une tentative d'implémentation de l'attaque par DPA
sur RSA.
Note: Les résultats obtenus sont FAUX !
La documentation (payante) est disponible à :
http://www.springerlink.com/content/4ugk06uu0y8hf5ue/

220
src/Java/DPA/src/dpa/RsaTest.java

@ -0,0 +1,220 @@
package dpa;
import java.math.*;
import java.io.*;
/** Cette classe regroupe l'implémentation de la DPA sur RSA.
* Note: C'est une version de test !
*
* Mode d'emploi:
* Il faut placer les traces de courant dans le répertoire "traces".
*
* Résultats:
* Les résultats sont FAUX.
*
* A faire:
* Voir pourquoi les résultats sont faux. La documentation (payante)
* est disponible à http://www.springerlink.com/content/4ugk06uu0y8hf5ue/
*
* Les traces de courant sont disponibles sur
* https://projects.itix.fr/studies/DPA/trac/wiki/TracesDeCourant
*
* @author nicolas.masse
*/
public class RsaTest {
public static void main(String[] args) {
BigInteger[] msg = new BigInteger[5000];
for (int i = 0; i < 5000; i++) {
try {
BufferedReader in = new BufferedReader(new FileReader("traces/msg_" + goodform(i+1) + ".dat"));
msg[i] = new BigInteger(in.readLine());
} catch (IOException ex) {
ex.printStackTrace();
System.exit(1);
}
if ((i+1) % 1000 == 0) {
System.out.println("Loaded " + (i+1) + " clear messages...");
}
}
int [][] traces = new int[5000][3536];
for (int i = 0; i < 5000; i++) {
try {
BufferedReader in = new BufferedReader(new FileReader("traces/SM_32_" + goodform(i+1) + ".dat"));
for (int j = 0; j < 3536; j++) {
traces[i][j] = Integer.parseInt(in.readLine());
}
} catch (IOException ex) {
ex.printStackTrace();
System.exit(1);
}
if ((i+1) % 1000 == 0) {
System.out.println("Loaded " + (i+1) + " traces...");
}
}
// The public key
BigInteger n = new BigInteger("115753540889062431344172474906327728114200335452658415236258067817852290090837");
BigInteger e = new BigInteger("3");
System.out.println("n = " + n);
System.out.println("Checking n...");
if (n.isProbablePrime(1024)) {
System.out.println(" n is probably a prime number.");
} else {
System.out.println(" n is definitely NOT a prime number.");
}
System.out.println("e = " + e);
System.out.println("Checking e...");
if (e.isProbablePrime(1024)) {
System.out.println(" e is probably a prime number.");
} else {
System.out.println(" e is definitely NOT a prime number.");
}
System.out.println("Breaking the key...");
BigInteger key = dpa(256, msg, traces, n);
//BigInteger key = new BigInteger("77169027259374954229448316604218485408995432318477845515909257059866234615730");
System.out.println(" d = " + key);
System.out.println("Checking the private key...");
if (key.isProbablePrime(1024)) {
System.out.println(" the private key is probably a prime number.");
} else {
System.out.println(" the private key is definitely NOT a prime number.");
}
System.out.println("Verifying (sign-verif)...");
BigInteger msg_orig = msg[0];
BigInteger sign = msg_orig.modPow(key, n);
BigInteger msg_verif = sign.modPow(e, n);
if (msg_orig.equals(msg_verif)) {
System.out.println(" The key is the good one !");
} else {
System.out.println(" Sorry, this is not the good key...");
System.out.println(" original message = " + msg_orig);
System.out.println(" verified message = " + msg_verif);
}
//System.out.println("Verifying...");
//BigInteger
}
public static BigInteger dpa(int bit, BigInteger[] msg, int[][] traces, BigInteger n) {
BigInteger res = null;
if (bit == 1) {
res = new BigInteger("1");
} else {
BigInteger key = dpa(bit - 1, msg, traces, n);
key = key.multiply(new BigInteger("2"));
BigInteger key2 = key.multiply(new BigInteger("2"));
BigInteger key1 = key.add(BigInteger.ONE);
boolean alreadyChosen = false;
if (dpaStep(key2, msg, traces, n)) {
res = key;
alreadyChosen = true;
}
if (dpaStep(key1, msg, traces, n)) {
res = key1;
if (alreadyChosen) {
System.out.println("Error: can't decide, two matches !");
System.exit(1);
}
alreadyChosen = true;
}
if (!alreadyChosen) {
System.out.println("Error: can't decide, no match !");
System.exit(1);
}
}
System.out.println("bit = " + bit + ", key = " + res);
return res;
}
public static boolean dpaStep(BigInteger power, BigInteger[] msg, int[][] traces, BigInteger n) {
int tlen = traces[0].length;
int[] c0 = new int[tlen];
int[] c1 = new int[tlen];
int[] diffP = new int[tlen];
int n0 = 0;
int n1 = 0;
for (int j = 0; j < traces.length; j++) {
BigInteger m = msg[j];
if (sel(m.modPow(power,n))) {
for (int k = 0; k < tlen; k++) {
c0[k] += traces[j][k];
}
n0++;
} else {
for (int k = 0; k < tlen; k++) {
c1[k] += traces[j][k];
}
n1++;
}
}
// Mean computation
int sum = 0;
for (int k = 0; k < tlen; k++) {
diffP[k] = c0[k] / n0 - c1[k] / n1;
sum += diffP[k];
}
double mean = sum / traces.length;
// Standard deviation computation
double stddev = 0;
for (int k = 0; k < tlen; k++) {
stddev += (diffP[k] - mean) * (diffP[k] - mean);
}
stddev = Math.sqrt(stddev / traces.length);
int max = 0;
for (int k = 0; k < tlen; k++) {
if (Math.abs(diffP[k]) > max) {
max = diffP[k];
}
}
boolean spike = false;
if (max > 5 * stddev) {
spike = true;
}
return spike;
}
public static boolean sel(BigInteger i) {
// bits are numbered from 0
return i.testBit(26);
}
public static String goodform(int i) {
String str = Integer.toString(i);
int len = str.length();
for (int j = 0; j < 5 - len; j++) {
str = "0" + str;
}
return str;
}
}

233
src/Java/DPA/src/dpa/RsaTest2.java

@ -0,0 +1,233 @@
package dpa;
import java.math.*;
import java.io.*;
/** Version multi-bits de la DPA sur RSA.
* Note: C'est une version de test !
*
* Mode d'emploi:
* Il faut placer les traces de courant dans le répertoire "traces".
*
* Résultats:
* Les résultats sont FAUX.
*
* A faire:
* Voir pourquoi les résultats sont faux. La documentation (payante)
* est disponible à http://www.springerlink.com/content/4ugk06uu0y8hf5ue/
*
* Les traces de courant sont disponibles sur
* https://projects.itix.fr/studies/DPA/trac/wiki/TracesDeCourant
*
* @author nicolas.masse
*/
public class RsaTest2 {
public static void main(String[] args) {
int ntraces = 5000;
BigInteger[] msg = new BigInteger[ntraces];
for (int i = 0; i < ntraces; i++) {
try {
BufferedReader in = new BufferedReader(new FileReader("traces/msg_" + goodform(i+1) + ".dat"));
msg[i] = new BigInteger(in.readLine());
} catch (IOException ex) {
ex.printStackTrace();
System.exit(1);
}
if ((i+1) % 1000 == 0) {
System.out.println("Loaded " + (i+1) + " clear messages...");
}
}
int [][] traces = new int[ntraces][3536];
for (int i = 0; i < ntraces; i++) {
try {
BufferedReader in = new BufferedReader(new FileReader("traces/SM_32_" + goodform(i+1) + ".dat"));
for (int j = 0; j < 3536; j++) {
traces[i][j] = Integer.parseInt(in.readLine());
}
} catch (IOException ex) {
ex.printStackTrace();
System.exit(1);
}
if ((i+1) % 1000 == 0) {
System.out.println("Loaded " + (i+1) + " traces...");
}
}
// The public key
BigInteger n = new BigInteger("115753540889062431344172474906327728114200335452658415236258067817852290090837");
BigInteger e = new BigInteger("3");
System.out.println("n = " + n);
System.out.println("Checking n...");
if (n.isProbablePrime(1024)) {
System.out.println(" n is probably a prime number.");
} else {
System.out.println(" n is definitely NOT a prime number.");
}
System.out.println("e = " + e);
System.out.println("Checking e...");
if (e.isProbablePrime(1024)) {
System.out.println(" e is probably a prime number.");
} else {
System.out.println(" e is definitely NOT a prime number.");
}
System.out.println("Breaking the key...");
BigInteger key = dpa(256, msg, traces, n);
//BigInteger key = new BigInteger("77169027259374954229448316604218485408995432318477845515909257059866234615730");
System.out.println(" d = " + key);
System.out.println("Checking the private key...");
if (key.isProbablePrime(1024)) {
System.out.println(" the private key is probably a prime number.");
} else {
System.out.println(" the private key is definitely NOT a prime number.");
}
System.out.println("Verifying (sign-verif)...");
BigInteger msg_orig = msg[0];
BigInteger sign = msg_orig.modPow(key, n);
BigInteger msg_verif = sign.modPow(e, n);
if (msg_orig.equals(msg_verif)) {
System.out.println(" The key is the good one !");
} else {
System.out.println(" Sorry, this is not the good key...");
System.out.println(" original message = " + msg_orig);
System.out.println(" verified message = " + msg_verif);
}
//System.out.println("Verifying...");
//BigInteger
}
public static BigInteger dpa(int bit, BigInteger[] msg, int[][] traces, BigInteger n) {
BigInteger res = null;
if (bit == 1) {
res = new BigInteger("1");
} else {
BigInteger key = dpa(bit - 1, msg, traces, n);
key = key.multiply(new BigInteger("2"));
BigInteger key2 = key.multiply(new BigInteger("2"));
BigInteger key1 = key.add(BigInteger.ONE);
boolean alreadyChosen = false;
if (dpaStep(key2, msg, traces, n)) {
res = key;
alreadyChosen = true;
}
if (dpaStep(key1, msg, traces, n)) {
res = key1;
if (alreadyChosen) {
System.out.println("Error: can't decide, two matches !");
System.exit(1);
}
alreadyChosen = true;
}
if (!alreadyChosen) {
System.out.println("Error: can't decide, no match !");
System.exit(1);
}
}
System.out.println("bit = " + bit + ", key = " + res);
return res;
}
public static boolean dpaStep(BigInteger power, BigInteger[] msg, int[][] traces, BigInteger n) {
int tlen = traces[0].length;
int[] c0 = new int[tlen];
int[] c1 = new int[tlen];
int[] diffP = new int[tlen];
int n0 = 0;
int n1 = 0;
for (int j = 0; j < traces.length; j++) {
BigInteger m = msg[j];
int sel = sel(m.modPow(power,n));
if (sel > 0) {
for (int k = 0; k < tlen; k++) {
c0[k] += traces[j][k];
}
n0++;
} else if (sel < 0) {
for (int k = 0; k < tlen; k++) {
c1[k] += traces[j][k];
}
n1++;
}
}
// Mean computation
int sum = 0;
for (int k = 0; k < tlen; k++) {
diffP[k] = c0[k] / n0 - c1[k] / n1;
sum += diffP[k];
}
double mean = sum / (n0 + n1);
// Standard deviation computation
double stddev = 0;
for (int k = 0; k < tlen; k++) {
stddev += (diffP[k] - mean) * (diffP[k] - mean);
}
stddev = Math.sqrt(stddev / (n0 + n1));
int max = 0;
for (int k = 0; k < tlen; k++) {
if (Math.abs(diffP[k]) > max) {
max = diffP[k];
}
}
boolean spike = false;
if (max > 5 * stddev) {
spike = true;
}
return spike;
}
public static int sel(BigInteger i) {
// bits are numbered from 0
int res = 0;
if (i.testBit(26) && i.testBit(25) && i.testBit(24)) {
res = 1;
} else if (!(i.testBit(26) || i.testBit(25) || i.testBit(24)) ) {
res = -1;
}
return res;
}
public static String goodform(int i) {
String str = Integer.toString(i);
int len = str.length();
for (int j = 0; j < 5 - len; j++) {
str = "0" + str;
}
return str;
}
}

1
src/Java/DPA/traces

@ -0,0 +1 @@
../../Mathematica/DPA-RSA/traces

10
src/Mathematica/README

@ -0,0 +1,10 @@
Ces deux feuilles de calcul Mathematica sont des essais d'implémentation
de la DPA suite à l'intervention de M.PAILLIER à l'université de CAEN.
Les traces de courant sont disponibles à
https://projects.itix.fr/studies/DPA/trac/wiki/TracesDeCourant
Etat d'avancement: les résultats sont probablement FAUX.
Note: ces deux feuilles sont grandement basées sur le travail de M.PAILLIER.

8422
src/Mathematica/dpa-mb.nb

File diff suppressed because it is too large

7026
src/Mathematica/dpa.nb

File diff suppressed because it is too large

67
src/Matlab/CPA/cpa_compute_cpa.m

@ -0,0 +1,67 @@
function [best_guess, max_corr_factor, max_corr_sample_id] = cpa_compute_cpa(directory_name, variant, max_curve_num)
%CPA_COMPUTE_CPA(DIRECTORY_NAME, VARIANT)
% Use the curves and the associated cleartext in the provided directory to compute the key chunks
% associated with the des first round subkey
% return the best guess, one per sbox
% the maximum correlation factor, one per sbox
% the index in the curve of the sample associated with the
% maximum correlation factor.
% initializing results arrays: max correlation factor for each sbox, and
% the associated guess on the key chunk
max_corr_factor = zeros(1,8);
max_corr_sample_id = zeros(1,8);
best_guess = zeros(1,8);
% preloading the curves data (40 * 50ko curves)
curves = cpa_load_curves(directory_name, variant, max_curve_num);
num_curve = size(curves, 1);
num_sample = size(curves, 2);
% computing standarg deviation among curves same timestep samples;
std_curve_sample = std(curves);
mean_curve_sample = mean(curves, 1);
% iterating over all the possible guess
for guess = 0:63
disp(guess);
% get the hamming weight assotiated with the cleartexts, one column per
% sbox
weights = cpa_get_hamming_weigth(directory_name, guess, num_curve);
% computing standard deviation and mean
std_hamming = std(weights);
mean_hamming = mean(weights, 1);
%iterating over sbox
for sbox = 1:8
w = weights(:, sbox);
max_corr = 0;
max_corr_id = 0;
%iterating over samples to compute correlation curve
for i = 1:num_sample
std_curve_sample_i = std_curve_sample(i);
std_hamming_sbox = std_hamming(sbox);
if std_curve_sample_i ~= 0 & std_hamming_sbox ~= 0
correlation_factor= (mean(curves(:,i) .* w, 1) - (mean_curve_sample(i) * mean_hamming(sbox))) / (std_curve_sample_i * std_hamming_sbox);
if correlation_factor > max_corr
max_corr = correlation_factor;
max_corr_id = i;
end
end
end
if max_corr > max_corr_factor(sbox)
max_corr_factor(sbox) = max_corr;
max_corr_sample_id(sbox) = max_corr_id;
best_guess(sbox) = guess;
end
end
end

10
src/Matlab/CPA/cpa_get_hamming_weigth.m

@ -0,0 +1,10 @@
function [weights] = cpa_get_hamming_weigth(directory_name, guess, num_curve)
%CPA_GET_HAMMING_WEIGHT(DIRECTORY_NAME, GUESS)
% return array containing the hamming weigth of
% the handled cleartext when the given guess is used, one line per sbox
weights = [];
for sbox = 1:8
weights = [weights, cpa_get_hamming_weigth_per_sbox(directory_name, sbox, guess, num_curve)];
end

21
src/Matlab/CPA/cpa_get_hamming_weigth_per_sbox.m

@ -0,0 +1,21 @@
function [weights] = cpa_get_hamming_weigth_per_sbox(directory_name, sbox, guess, num_curve)
%CPA_GET_HAMMING_WEIGHT_PER_SBOX(DIRECTORY_NAME, SBOX, GUESS)
% return an array containing the hamming weigth of
% the handled cleartext when the given sbox and guess is used
filename = [directory_name, '/cpa/', 'S', num2str(sbox), '/outbox.64_4.s', num2str(sbox), '.p00.g', num2str(guess, '%02d')];
fid = fopen(filename, 'r');
weights = [];
i = 0;
while i < num_curve & ~ feof(fid)
str = fgetl(fid);
data = sscanf(str, '%d%d');
weights = [weights; data(2)];
i = i + 1;
end
fclose(fid);

23
src/Matlab/CPA/cpa_load_curves.m

@ -0,0 +1,23 @@
function [curves] = cpa_load_curves(directory_name, variant, max_curve_num)
%CPA_LOAD_CURVES(DIRECTORY_NAME, VARIANT, MAX_CURVE_NUM)
% a null max_num_curve lead to load all the curves in the specified directory
% return an array (size: [num_curves, num_sample_per_curve])
curves = [];
num_curve = 0;
filename = [directory_name, '/curves/00/', variant, '.', num2str(num_curve, '%05d')];
fid = fopen(filename,'r');
% try to load max_curve_num curve files in the directory
while ((max_curve_num == 0) | (num_curve < max_curve_num)) & fid ~= -1
curves = [curves; fread(fid, inf, 'uint8')'];
fclose(fid);
num_curve = num_curve + 1;
filename = [directory_name, '/curves/00/', variant, '.', num2str(num_curve, '%05d')];
fid = fopen(filename,'r');
end

16
src/Matlab/DPA/dpa_des_block2hexstr.m

@ -0,0 +1,16 @@
function [ str ] = dpa_des_block2hexstr(block)
%DES_DPA(BLOCK) to display a block in hexadecimal format. block length must
% be a multiple of 8. Return a string
numblock = (size(block, 2) / 8) - 1;
str = '';
p2 = 2 .^ [7:-1:0];
for i = [0 : numblock]
id = i * 8;
subblock = block(id + 1:id + 8);
val = subblock * p2';
str = strcat(str, dec2hex(val,2));
end

15
src/Matlab/DPA/dpa_des_deckeychunk2block.m

@ -0,0 +1,15 @@
function [ block ] = dpa_des_deckeychunk2block(dec_key_chunks)
%DPA_DES_DECKEYCHUNK2BLOCK(DEC_KEY_CHUNKS) compute a round key block from an array
%of decimal values, one per sbox (value 1 for sbox 1 etc...)
%representation
num_chunks = size(dec_key_chunks, 2);
block = [];
for chunk = dec_key_chunks
str = dec2bin(chunk,6);
for c = str
block = [block, str2num(c)];
end
end

160
src/Matlab/DPA/dpa_des_display_mean.m

@ -0,0 +1,160 @@
function [g, b] = dpa_des_display_mean(num_samples, power_model_name, tested_sbox)
%DES_DISPLAY_MEAN COMPUTES A DPA ON ONE KEY CHUNK AND DISPLAY THE RESULTING PLOT)
% figure 1 resulting from a good key chunk, figure 2 resulting from afalse hypothesis
%on the key chunk;
key = round(rand(1,64));
keys = des_key_schedule(key);
lastkey = keys(16,:);
[pmodel spdetector] = dpa_des_power_model(power_model_name);
% computing a dumb power trace to get its size
spower = size(pmodel(zeros(1,64)), 2);
%tested_sbox = 1;
i = ((tested_sbox - 1) * 6) + 1;
good_key_chunk = lastkey(i:i+5);
bad_key_chunk = round(rand(1,6));
%good_key_chunk = bad_key_chunk;
while all(bad_key_chunk == good_key_chunk)
bad_key_chunk = round(rand(i,i+5));
end
% GA = Good key chunk, tested bit = 0
% GB = Good key chunk, tested bit = 1
% BA = Bad key chunk, tested bit = 0
% BB = Bad key chunk, tested bit = 1
trace_ga = zeros(1,spower);
trace_gb = zeros(1,spower);
trace_ba = zeros(1,spower);
trace_bb = zeros(1,spower);
s = num_samples;
nga = 0;
ngb = 0;
nba = 0;
nbb = 0;
tested_bit_index = 1 + (tested_sbox - 1) * 4;
while s > 0
plaintext = round(rand(1,64));
[ciphertext power] = dpa_des_pencryption(plaintext, keys, pmodel);
% oracle using the good key chunk
r = dpa_des_selection_function(ciphertext, tested_sbox, good_key_chunk);
if r == 0
trace_ga = trace_ga + power;
nga = nga + 1;
else
trace_gb = trace_gb + power;
ngb = ngb + 1;
end
% oracle using the erroneous key chunk
r = dpa_des_selection_function(ciphertext, tested_sbox, bad_key_chunk);
if r == 0
trace_ba = trace_ba + power;
nba = nba + 1;
else
trace_bb = trace_bb + power;
nbb = nbb + 1;
end
s = s - 1;
end
if nga ~= 0
trace_ga = trace_ga / nga;
end
if ngb ~= 0
trace_gb = trace_gb / ngb;
end
if nba ~= 0
trace_ba = trace_ba / nba;
end
if nbb ~= 0
trace_bb = trace_bb / nbb;
end
g = trace_ga - trace_gb;
b = trace_ba - trace_bb;
figure(1);
x = 1:size(g,2);
n = 20;
f = ones(1, n) / n;
lg = conv(f, g);
lb = conv(f, b);
lg = lg(1, 1 : spower);
lb = lb(1, 1 : spower);
% Some statistics (mean and standard deviation)
mlg = mean(lg);
mlb = mean(lb);
slg = std(lg);
slb = std(lb);
disp('dpaspike');
disp(dpa_des_spike(g));
disp(dpa_des_spike(b));
disp('/dpaspike');
nstd = 10;
% Plot the raw data
subplot(3,2,1);
plot(x, g, '-g');
subplot(3,2,2);
plot(x, b, '-r');
% Plot the filtered (smoothed) data with the limits
subplot(3,2,3);
hold on;
plot(x, lg, '-g');
plot([1 spower], [1 1] * nstd * (mlg - slg), '-b');
plot([1 spower], [1 1] * nstd * (mlg + slg), '-b');
subplot(3,2,4);
hold on;
plot(x, lb, '-r');
plot([1 spower], [1 1] * nstd * (mlb - slb), '-b');
plot([1 spower], [1 1] * nstd * (mlb + slb), '-b');
subplot(3,2,5);
n2 = 40;
[n, xout] = hist(lg, n2);
sumi = 0; for i = [1 : n2]; sumi = sumi + n(i); n(i) = sumi / spower; end
hold on;
plot(xout, n, '-g');
plot([1 1] * nstd * (mlg + slg), [0 1], '-b');
plot([1 1] * nstd * (mlg - slg), [0 1], '-b');
subplot(3,2,6);
[n, xout] = hist(lb, n2);
sumi = 0; for i = [1 : n2]; sumi = sumi + n(i); n(i) = sumi / spower; end
hold on;
plot(xout, n, '-r');
plot([1 1] * nstd * (mlb + slb), [0 1], '-b');
plot([1 1] * nstd * (mlb - slb), [0 1], '-b');
spdetector(g)
spdetector(b)

77
src/Matlab/DPA/dpa_des_dpa.m

@ -0,0 +1,77 @@
function [ keys ] = dpa_des_dpa(traces, ciphers, spike_detector)
%DES_DPA(TRACES,CIPHERS,CLEARS) Simple version of the DPA on DES
% Returns the possible keys, using the provided traces and ciphers
n_traces = size(traces, 1);
n_samples = size(traces, 2);
sbox_num = 8;
hypothesis_spike_max = zeros(1, sbox_num);
hypothesis_subkey = zeros(1, sbox_num);
% we iterate over the 64 possible subkeys
for ikey = [0 : 63]
fprintf(1, 'test sous clé %d\n', ikey);
%if mod(i,16) == 0
% figure((i / 16) + 1);
%end
% compute the key chunk block
key_chunk = dec2bin(ikey, 6) == '1';
% place to store 8 parallele dpa over the 8 s-box
trace_a = zeros(sbox_num, n_samples);
trace_b = zeros(sbox_num, n_samples);
na = zeros(1,sbox_num);
nb = zeros(1,sbox_num);
% iterate over all the trace
for n_trace = [1 : n_traces]
% iterate over the 8 sbox
for n_sbox = [1:sbox_num]
r = dpa_des_selection_function(ciphers(n_trace,:), n_sbox, key_chunk);
if r == 0
trace_a(n_sbox,:) = trace_a(n_sbox,:) + traces(n_trace,:);
na(n_sbox) = na(n_sbox) + 1;
else
trace_b(n_sbox,:) = trace_b(n_sbox,:) + traces(n_trace,:);
nb(n_sbox) = nb(n_sbox) + 1;
end
end
end
% iterate over the 8 sbox
for n_sbox = [1:sbox_num]
if na(n_sbox) ~= 0
trace_a(n_sbox,:) = trace_a(n_sbox,:) / na(n_sbox);
end
if nb(n_sbox) ~= 0
trace_b(n_sbox,:) = trace_b(n_sbox,:) / nb(n_sbox);
end
spike_value = spike_detector(trace_a(n_sbox,:) - trace_b(n_sbox,:));
%if spike_value == 2
% fprintf(1, 'key chunk num: %d found, %s\n', n_sbox,dec2bin(ikey,6)) ;
%end
if spike_value > hypothesis_spike_max(n_sbox)
hypothesis_spike_max(n_sbox) = spike_value;
hypothesis_subkey(n_sbox) = ikey;
end
end
end
% rebuild the last key using the chosen subkey
computed_last_key = [];
for n_sbox = [1:sbox_num]
k = dec2bin(hypothesis_subkey(n_sbox), 6) == '1';
computed_last_key = [computed_last_key k];
end
keys = dpa_des_reverse_ks(computed_last_key);
%keys = computed_last_key;

48
src/Matlab/DPA/dpa_des_dpa_test.m

@ -0,0 +1,48 @@
function [good_bit] = dpa_des_dpa_test(num_samples, power_model)
%DES_DPA_TEST(NUM_SAMPLES, POWER_MODEL) Tests the simple version of the DPA algorithm
s = num_samples;
% we build a random key
key = round(rand(1,64));
% raz parity bit of the key. reverse key schedule do the same
key(8:8:64) = 0;
keys = des_key_schedule(key);
[pmodel spdetector] = dpa_des_power_model(power_model);
traces = [];
ciphers = [];
clears = [];
while s > 0
plaintext = round(rand(1,64));
[ciphertext power] = dpa_des_pencryption(plaintext, keys, pmodel);
clears = [clears ; plaintext];
ciphers = [ciphers ; ciphertext];
traces = [traces ; power];
s = s - 1;
end
returned_keys = dpa_des_dpa(traces, ciphers, spdetector);
%if all(returned_keys == keys(16,:))
% disp('La clé est trouvée');
%end
fprintf(1, 'original key:\t%s\n', dpa_des_block2hexstr(key));
for i = [1 : size(returned_keys, 1)]
%disp(sum(returned_keys(i, :) == key) - 8);
k = returned_keys(i, :);
if all(k == key)
fprintf(1, 'found key\t%s\n', dpa_des_block2hexstr(k));
end
end

6
src/Matlab/DPA/dpa_des_expand_key_chunk.m

@ -0,0 +1,6 @@
function key48 = des_expand_key_ckunk(key_chunk, key_chunk_number )
%DES_EXPAND_KEY_CHUNK(KEY_CHUNK, KEY_CHUNK_NUMBER)
% compute a 48 bits key based on the provided chunk (6 bits), concatenate with 0
% key_chunk_number indicate where will be the chunk in the key48 (1 <= x <= 8)
key48 = horzcat(zeros(1, (key_chunk_number - 1) * 6), key_chunk, zeros(1, 6 * (8 - key_chunk_number)));

25
src/Matlab/DPA/dpa_des_get_power.m

@ -0,0 +1,25 @@
function [ power ] = dpa_des_get_power( block )
%DES_GET_POWER COMPUTES THE POWER TRACE FROM A BIT BLOCK)
psize = 10000;
%power = rand(1, psize) * 0.5;
power = rand(1, psize);
for j = 1:64;
i = floor(j * psize / 65);
power(i : i + psize / 1000) = power(i : i + psize / 1000) + ((0.5 - block(j)) * 0.3);
end
%{
on définit 64 morceau de 10 bits consécutifs sur la trace de courant
à chaque bit d'un morceau est ajouté la valeur (coefficientée) du bit du block
correspondant à ce morceau
exemple, la valeur du bit 8 du bloc de données d'entrée
est ajoutée au 10 bits du 8ème bloc de la trace de courant,
c'est a dire les bits allant de 8 * (10000/65) a (10000/65) + 10
%}

14
src/Matlab/DPA/dpa_des_hexstr2block.m

@ -0,0 +1,14 @@
function [ block ] = dpa_des_hexstr2block(str)
%DPA_DES_HEXSTR2BLOCK(STR) compute a key block from an hexadecimal string
%representation
block = [];
for i = str
num = hex2dec(i);
bin = dec2bin(num,4);
for i = bin
block = [block, str2num(i)];
end
end

18
src/Matlab/DPA/dpa_des_oracle.m

@ -0,0 +1,18 @@
function block = dpa_des_oracle( ciphertext, tested_sbox, key_chunk )
%DES_ORACLE(CIPHERTEXT, TESTED_SBOX, KEY_CHUNK)
%
% Return the value, before the last des round, of the four bits
% modified by the specified key_chunk during the last round
% expand the key chunk to a 48 bit key
key48 = dpa_des_expand_key_chunk(key_chunk, tested_sbox);
% invert final permutation (aka initial permutation) to retrive
% last des round result
data = des_initial_permutation(ciphertext);
% reapply last round
block = des_round(data, key48);

50
src/Matlab/DPA/dpa_des_oracle_test.m

@ -0,0 +1,50 @@
function [ good_response, false_response ] = dpa_des_oracle_test(number_of_test)
%DES_ORACLE_TEST(NUMBER_OF_TEST) Return the number of oracle's good and false response, after <number_of_test>
good_response = 0;
false_response = 0;
for test = 1:number_of_test
% choose a plaintext and a key to use in this test
keys = round(rand(1,64));
plaintext = round(rand(1,64));
if size(keys,1) == 1
keys = des_key_schedule(keys);
end
data = des_initial_permutation(plaintext);
for rnd = 1:15
data = des_round(data, keys(rnd,:));
data = des_block_interchange(data);
end
% store the value of the left block before applying last round
before_16_data = data(1:32);
before_16_data = dpa_des_reverse_permutation(before_16_data);
data = des_round(data, keys(16,:));
ciphertext = des_final_permutation(data);
lastkey48 = keys(16,:);
for sbox_number = [1:8]
id32 = ((sbox_number - 1) * 4) + 1;
id48 = ((sbox_number - 1) * 6) + 1;
block = dpa_des_oracle(ciphertext, sbox_number, lastkey48(id48 : id48 + 5));
if all(block == before_16_data(id32:id32 + 3)) == 1
good_response = good_response + 1;
else
false_response = false_response + 1;
end
end
end

21
src/Matlab/DPA/dpa_des_pencryption.m

@ -0,0 +1,21 @@
function [ ciphertext power ] = dpa_des_pencryption( plaintext, keys, model )
%DES_PENCRYPTION(PLAINTEXT, KEYS, MODEL)
%Executes the DES algorithm and computes a power trace using the given model
% compute subkeys if only master key is provided
if size(keys,1) == 1
keys = des_key_schedule(keys);
end
data = des_initial_permutation(plaintext);
for round = 1:15
data = des_round(data, keys(round,:));
data = des_block_interchange(data);
end
power = model(data);
data = des_round(data, keys(16,:));
ciphertext = des_final_permutation(data);

14
src/Matlab/DPA/dpa_des_power_model.m

@ -0,0 +1,14 @@
function [power criteria] = dpa_des_power_model(model_name)
%DES_POWER_MODEL(MODEL_NAME)
switch model_name
case 'des_power1'
power = @dpa_des_get_power;
criteria = @dpa_des_spike;
case 'des_power2'
power = @dpa_des_power_simplest_model;
criteria = @dpa_des_power_simplest_model_criteria;
otherwise
power = 0;
criteria = 0;
end

8
src/Matlab/DPA/dpa_des_power_simplest_model.m

@ -0,0 +1,8 @@
function [ power ] = dpa_des_power_simplest_model( block )
%DES_POWER_SIMPLEST_MODEL( BLOCK ) Computes a simple "over-correlated" power trace
%from a bit 64 bits block.
power = zeros(1, size(block,2));
power = (-2 * block) + 1;

4
src/Matlab/DPA/dpa_des_power_simplest_model_criteria.m

@ -0,0 +1,4 @@
function [ spike ] = dpa_des_power_simplest_model_criteria(mean)
%DES_POWER_SIMPLEST_MODEL_CRITERIA(MEAN ) return the peak height
spike = max(mean);

78
src/Matlab/DPA/dpa_des_reverse_ks.m

@ -0,0 +1,78 @@
function [ masterKeys64 ] = dpa_des_reverse_ks( lastKey48 )
%DES_REVERSE_KS(LAST_SUBKEY48) Recover a part of the master key using the
%last subkey. Returns the list of all possible subkeys.
% IPC2 is the reverse of PC2, its computation can be done using :
%{
IPC2 = zeros(1,56);
for i = [1:48]; IPC2(PC2(i)) = i; end
%}
IPC2 = [5 24 7 16 6 10 20 18 0 12 3 15 23 1 9 19 2 0 14 22 11 0 13 4 0 17];
IPC2 = [IPC2 21 8 47 31 27 48 35 41 0 46 28 0 39 32 25 44 0 37 34 43 29];
IPC2 = [IPC2 36 38 45 33 26 42 0 30 40];
% We do not need to invert the shifts since C and D are 28bits wide and
% there are 28 shifts between C0 (resp. D0) and C16 (resp. D16).
% IPC1 is the reverse of PC1, its computation can be done using :
%{
IPC1 = zeros(1,64);
for i = [1:56]; IPC1(PC1(i)) = i; end
%}
IPC1 = [8 16 24 56 52 44 36 0 7 15 23 55 51 43 35 0 6 14 22 54 50 42];
IPC1 = [IPC1 34 0 5 13 21 53 49 41 33 0 4 12 20 28 48 40 32 0 3 11 19 27];
IPC1 = [IPC1 47 39 31 0 2 10 18 26 46 38 30 0 1 9 17 25 45 37 29 0];
% Computes the composition "invP = IPC1 o IPC2"
invP = zeros(1,64);
for i = [1:64];
j = IPC1(i);
if j ~= 0;
k = IPC2(j);
if k ~= 0;
invP(i) = k;
end
end
end
% Find the free variables
freePos = [];
for i = [1:64];
if invP(i) == 0 && rem(i, 8) ~= 0;
freePos = [freePos i];
end
end
% Find 48 bits of the master key
incompleteKey = zeros(1,64);
for i = [1:64];
if (invP(i) ~= 0);
incompleteKey(i) = lastKey48(invP(i));
end
end
% 256 keys
masterKeys64 = zeros(256, 64);
% Find the 256 possible keys
for i = [0:255];
v = bitget(uint8(i), 8:-1:1);
masterKeys64(i + 1, :) = incompleteKey;
for j = [1:8];
masterKeys64(i + 1, freePos(j)) = v(j);
end
end
%{
key = 0;
keyRef = round(rand(1,64));
keyRef(8:8:64) = 0;
keysRef = des_key_schedule(keyRef);
lastKeyRef = keysRef(16,:);
keys = dpa_des_reverse_ks(lastKeyRef);
for i = [1:256]; if all(keys(i,:) == keyRef); key = keys(i,:); break; end; end;
key
%}

22
src/Matlab/DPA/dpa_des_reverse_permutation.m

@ -0,0 +1,22 @@
function [ outBlock32 ] = dpa_des_reverse_permutation( inBlock32 )
%DES_INVERSE_PERMUTATION DO REVERSE OF THE IN-ROUND PERMUTATION)
% Test case :
%{
in = [1 : 32];
ret = des_inverse_permutation(in);
ref = [16 7 20 21 29 12 28 17 1 15 23 26 5 18 31 10 2 8 24 14 32];
ref = [ref 27 3 9 19 13 30 6 22 11 4 25];
all(ret == ref)
%}
P = [9 17 23 31 13 28 2 18 24 16 30 6 26 20 10 1 8 14];
P = [P 25 3 4 29 11 19 32 12 22 7 5 27 15 21];
outBlock32 = zeros(1, 32);
for i = [1 : 32]
outBlock32(i) = inBlock32(P(i));
end

17
src/Matlab/DPA/dpa_des_selection_function.m

@ -0,0 +1,17 @@
function result = dpa_des_selection_function(ciphertext, tested_sbox, key_chunk )
%DES_SELECTION_FUNCTION(CIPHERTEXT, TESTED_SBOX, KEY_CHUNK)
%
% Return 0 or 1 depending of the value, before the round, of the first bit processed
% by the tested sbox.
block = dpa_des_oracle(ciphertext, tested_sbox, key_chunk);
% to keep bit processed by the sbox n in a contiguous block of bit
data = dpa_des_reverse_permutation(block(1:32));
tested_bit_index = 1 + (tested_sbox - 1) * 4;
result = data(tested_bit_index);

27
src/Matlab/DPA/dpa_des_spike.m

@ -0,0 +1,27 @@
function [ spike ] = dpa_des_spike( sample_mean )
%DES_SPIKE(MEAN) Detects a spike in sample_mean, the higher the returned value is, the
% more important the spike is.
% The filter
n = 20;
f = ones(1, n) / n;
spower = size(sample_mean, 2);
% We filter the samples mean
f_mean = conv(f, sample_mean);
f_mean = f_mean(1, 1 : spower);
% Some statistics
s_std = std(f_mean);
nstd = 10;
tmp = abs(f_mean);
spike = 0;
if any(tmp > nstd * s_std)
spike = max(tmp);
end

12
src/Matlab/DataEncryptionStandard/des_block_interchange.m

@ -0,0 +1,12 @@
function [ outBlock64 ] = des_block_interchange( inBlock64 )
%DES_BLOCK_INTERCHANGE Exchange the parts of a 64 bits block
% Test case :
%{
ret = des_block_interchange(1:64);
ref = [33:64, 1:32];
all(ret == ref)
%}
outBlock64 = [inBlock64(33:64) inBlock64(1:32)];

17
src/Matlab/DataEncryptionStandard/des_cipher_function.m

@ -0,0 +1,17 @@
function [ outBlock32 ] = des_cipher_function( inBlock32, subkey48 )
%DES_CIPHER_FUNCTION Encrypt a 32 bits block using a 48 bits subkey
% E function
inBlock48 = des_expand_box(inBlock32);
% XOR
outBlock48 = xor(inBlock48, subkey48);
% SBOXes
outBlock32 = zeros(1, 32);
for i = 1 : 8
outBlock32(((i - 1) * 4) + 1 : i * 4) = des_sbox(outBlock48(((i - 1) * 6) + 1 : i * 6), i);
end
% P
outBlock32 = des_permutation(outBlock32);

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save