| 355 | supportIndefLenMode = False |
| 356 | |
| 357 | def encodeValue(self, value, asn1Spec, encodeFun, **options): |
| 358 | if asn1Spec is not None: |
| 359 | value = asn1Spec.clone(value) |
| 360 | |
| 361 | octets = () |
| 362 | |
| 363 | # Cycle through subIds |
| 364 | for subOid in value.asTuple(): |
| 365 | if 0 <= subOid <= 127: |
| 366 | # Optimize for the common case |
| 367 | octets += (subOid,) |
| 368 | |
| 369 | elif subOid > 127: |
| 370 | # Pack large Sub-Object IDs |
| 371 | res = (subOid & 0x7f,) |
| 372 | subOid >>= 7 |
| 373 | |
| 374 | while subOid: |
| 375 | res = (0x80 | (subOid & 0x7f),) + res |
| 376 | subOid >>= 7 |
| 377 | |
| 378 | # Add packed Sub-Object ID to resulted RELATIVE-OID |
| 379 | octets += res |
| 380 | |
| 381 | else: |
| 382 | raise error.PyAsn1Error('Negative RELATIVE-OID arc %s at %s' % (subOid, value)) |
| 383 | |
| 384 | return octets, False, False |
| 385 | |
| 386 | |
| 387 | class RealEncoder(AbstractItemEncoder): |